I am attempting to write a c++ program and run it on a web server using .cgi. I've tried some examples found by googling and failed so i guess there is some other error rather than error in the actual code.
However, this is what the program i try with look like:
Code:
int main(int argc, char *argv[])
{std::cout<<"Content-type: text/html\n\n";
std::cout<<"along with some other text\n";
return(0);}
When I run this on the server I get the message
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.", which is the same error I have received when i've, for example, tried to run a perl script with some error in it.
Problem combining c++ and .cgi
Started by yuyujoke, Dec 03 2008 09:04 AM
2 replies to this topic
#1
Posted 03 December 2008 - 09:04 AM
|
|
|
#2
Posted 03 December 2008 - 09:45 AM
Try this since you don't use command line parameters and your code didn't include the necessary headers.
#include <iostream>
int main()
{
std::cout<<"Content-type: text/html\n\n";
std::cout<<"along with some other text\n";
return(0);
}
Also, the program has to be compiled to an executable file before it can be run on the server. It's not like Perl where you can just stuff the code in there and it'll be run.
#3
Posted 09 December 2008 - 12:21 AM
Are you writing your program on the server computer? If you compile it on your personal computer, leave it in debug mode, and then try to run it, it'll fail because the needed debug libraries won't be there. Make sure you compile in release mode to strip all the debug libraries out of your program.


Sign In
Create Account

Back to top









