aplelois
asked on
CGI
hello,
why is this when I try to compile my app..
#include <iostream.h>
using namespace std;
int main()
{
cout << "content-type: text/html" << endl << endl;
cout << "<HTML><BODY>" << endl;
cout << "<H1> Hello, World! </H1>" << endl;
cout << "</BODY></HTML>" << endl;
return 0;
}
------------------------
/home/virtual/site.net/var /www/cgi-b in)] $ gcc -o hello a.cpp
In file included from /usr/include/c++/3.3.2/bac kward/iost ream.h:31,
from a.cpp:2:
/usr/include/c++/3.3.2/bac kward/back ward_warni ng.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
/tmp/ccPB2kXj.o(.text+0x28 ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x2d ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x3d ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x42 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x52 ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x57 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x67 ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x6c ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x7c ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x81 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x9c ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0xa1 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0xb1 ): In function `main':
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0xb6 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0xf8 ): In function `__static_initialization_a nd_destruc tion_0(int , int)':
: undefined reference to `std::ios_base::Init::Init [in-charge ]()'
/tmp/ccPB2kXj.o(.text+0x12 7): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Ini t [in-charge]()'
/tmp/ccPB2kXj.o(.eh_frame+ 0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
why is this when I try to compile my app..
#include <iostream.h>
using namespace std;
int main()
{
cout << "content-type: text/html" << endl << endl;
cout << "<HTML><BODY>" << endl;
cout << "<H1> Hello, World! </H1>" << endl;
cout << "</BODY></HTML>" << endl;
return 0;
}
------------------------
/home/virtual/site.net/var
In file included from /usr/include/c++/3.3.2/bac
from a.cpp:2:
/usr/include/c++/3.3.2/bac
/tmp/ccPB2kXj.o(.text+0x28
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x2d
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x3d
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x42
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x52
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x57
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x67
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x6c
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x7c
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0x81
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0x9c
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0xa1
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0xb1
: undefined reference to `std::cout'
/tmp/ccPB2kXj.o(.text+0xb6
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/ccPB2kXj.o(.text+0xf8
: undefined reference to `std::ios_base::Init::Init
/tmp/ccPB2kXj.o(.text+0x12
: undefined reference to `std::ios_base::Init::~Ini
/tmp/ccPB2kXj.o(.eh_frame+
collect2: ld returned 1 exit status
ASKER
gcc -o hello a.cpp
/tmp/cc8xKCU7.o(.text+0x14 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/cc8xKCU7.o(.text+0x1c ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/cc8xKCU7.o(.text+0x29 ): In function `main':
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0x2e ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/cc8xKCU7.o(.text+0x37 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o stream<cha r, std::char_traits<char> >& (*)(std::basic_ostream<cha r, std::char_traits<char> >&))'
/tmp/cc8xKCU7.o(.text+0x40 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o stream<cha r, std::char_traits<char> >& (*)(std::basic_ostream<cha r, std::char_traits<char> >&))'
/tmp/cc8xKCU7.o(.text+0x4b ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/cc8xKCU7.o(.text+0x58 ): In function `main':
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0x5d ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/cc8xKCU7.o(.text+0x66 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o stream<cha r, std::char_traits<char> >& (*)(std::basic_ostream<cha r, std::char_traits<char> >&))'
/tmp/cc8xKCU7.o(.text+0x71 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/cc8xKCU7.o(.text+0x7e ): In function `main':
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0x83 ): In function `main':
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0xa9 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/cc8xKCU7.o(.text+0xb2 ): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o stream<cha r, std::char_traits<char> >& (*)(std::basic_ostream<cha r, std::char_traits<char> >&))'
/tmp/cc8xKCU7.o(.text+0xde ): In function `__static_initialization_a nd_destruc tion_0(int , int)':
: undefined reference to `std::ios_base::Init::Init [in-charge ]()'
/tmp/cc8xKCU7.o(.text+0x10 d): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Ini t [in-charge]()'
/tmp/cc8xKCU7.o(.eh_frame+ 0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
/tmp/cc8xKCU7.o(.text+0x14
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char,
/tmp/cc8xKCU7.o(.text+0x1c
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char,
/tmp/cc8xKCU7.o(.text+0x29
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0x2e
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/cc8xKCU7.o(.text+0x37
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o
/tmp/cc8xKCU7.o(.text+0x40
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o
/tmp/cc8xKCU7.o(.text+0x4b
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char,
/tmp/cc8xKCU7.o(.text+0x58
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0x5d
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/cc8xKCU7.o(.text+0x66
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o
/tmp/cc8xKCU7.o(.text+0x71
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char,
/tmp/cc8xKCU7.o(.text+0x7e
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0x83
: undefined reference to `std::cout'
/tmp/cc8xKCU7.o(.text+0xa9
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
/tmp/cc8xKCU7.o(.text+0xb2
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_o
/tmp/cc8xKCU7.o(.text+0xde
: undefined reference to `std::ios_base::Init::Init
/tmp/cc8xKCU7.o(.text+0x10
: undefined reference to `std::ios_base::Init::~Ini
/tmp/cc8xKCU7.o(.eh_frame+
collect2: ld returned 1 exit status
Well, since this is a C++ program, you should compile with g++ and not gcc
ASKER
500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
The server encountered an internal error or misconfiguration and was unable to complete your request.
ASKER
i have been trying for the last 5 hour to run a CGI C++ file in my server..
I downloaded a file from a website that came copiled already in C and
works fine but I can't get my own samples to work....
I downloaded a file from a website that came copiled already in C and
works fine but I can't get my own samples to work....
What format did the one you downloaded came in ?
Is the folder you placed this in the same ?
Is the server still up ... ie. can you still run the one you downloaded ?
Can you run the executable manually (on the server : ./hello) ?
Is the folder you placed this in the same ?
Is the server still up ... ie. can you still run the one you downloaded ?
Can you run the executable manually (on the server : ./hello) ?
Try to compile this one with gcc (it's a C program) :
#include <stdio.h>
int main() {
printf("content-type: text/html\n\n");
printf("Hello world");
return 0;
}
And see if you can run it as CGI from a browser.
#include <stdio.h>
int main() {
printf("content-type: text/html\n\n");
printf("Hello world");
return 0;
}
And see if you can run it as CGI from a browser.
ASKER
compiled fine, everything looks good... ok.. boom -> 500 Internal Server Error
Hi aplelois,
> #include <iostream.h>
FYI:
The above header is not part of the C++ standard, and therefore not portable.
It should not be used.
Use the following instead:
#include <iostream>
Mixing the non-standard iostream.h header with using namespace std, can cause problems compiling when other standard headers are included.
Cheers!
> #include <iostream.h>
FYI:
The above header is not part of the C++ standard, and therefore not portable.
It should not be used.
Use the following instead:
#include <iostream>
Mixing the non-standard iostream.h header with using namespace std, can cause problems compiling when other standard headers are included.
Cheers!
>> compiled fine, everything looks good... ok.. boom -> 500 Internal Server Error
Did you set the proper permissions for the file ? Check your HTTP server's manual to know which to set for CGI.
Are the settings for CGI all ok for the server ?
How about the 4 questions I asked earlier ?
Did you set the proper permissions for the file ? Check your HTTP server's manual to know which to set for CGI.
Are the settings for CGI all ok for the server ?
How about the 4 questions I asked earlier ?
ASKER
sorry Axter but Infinity08 already said that!!!
--Infinity08--
>>What format did the one you downloaded came in ?
here is the download file turbotraffictrader.com/dow nload/ttt- c-version2 -Linux.tgz
>>Is the folder you placed this in the same ?
yes, its in /cgi-bin/
>>Is the server still up ... ie. can you still run the one you downloaded ?
yes, its up
>>Can you run the executable manually (on the server : ./hello)
yes I can
--Infinity08--
>>What format did the one you downloaded came in ?
here is the download file turbotraffictrader.com/dow
>>Is the folder you placed this in the same ?
yes, its in /cgi-bin/
>>Is the server still up ... ie. can you still run the one you downloaded ?
yes, its up
>>Can you run the executable manually (on the server : ./hello)
yes I can
>> Did you set the proper permissions for the file ?
Just a follow-up of this : normally you need to chmod the file to 755 ...
Just a follow-up of this : normally you need to chmod the file to 755 ...
ASKER
yes i did this
chmod -R 755 hello.cgi
chmod -R 755 hello.cgi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>sorry Axter but Infinity08 already said that!!!
I just notice that.
When I first scrolled through your question, your first post and second post looked like on continuous post, and I din't see Infinity08's comment.
I just notice that.
When I first scrolled through your question, your first post and second post looked like on continuous post, and I din't see Infinity08's comment.
ASKER
thank you guys!! I got it!
>> thank you guys!! I got it!
So, what was the problem ? The .cgi extension ?
So, what was the problem ? The .cgi extension ?
ASKER
>>check logs
i was compiling the files as root so when thats why i was getting the 500 error
so what im doing now is
Upload source code compile it...
download the compiled file -> then Upload it again!!
then make 755 permision
i was compiling the files as root so when thats why i was getting the 500 error
so what im doing now is
Upload source code compile it...
download the compiled file -> then Upload it again!!
then make 755 permision
heh :)
btw : it's never a good idea to compile as root !!! Let alone anything else. Root should be kept for system management operations only !! And even then only when absolutely needed ... it prevents some less pleasant surprises :)
btw : it's never a good idea to compile as root !!! Let alone anything else. Root should be kept for system management operations only !! And even then only when absolutely needed ... it prevents some less pleasant surprises :)
#include <iostream>
instead of :
#include <iostream.h>