Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiling a C++ CGI source in Windows not to an EXE

Status
Not open for further replies.

TheFoxy

Programmer
Nov 22, 2002
48
GB
Hi, this problem has been plaguing me for literally months.

I have a short test C++ source here:

Problem is, as far as I know I need to compile to a .EXE, and rename to a .CGI, and upload it to my server to use it. However, my host does not allow .EXEs or renamed .EXEs due to security issues (btw, both my OS and the server's is Windows based).

So, has anyone any idea how to compile this baby into CGI NOT via compiling to an EXE?

I'm using Bloodshed Software's Dev-C++. (God I love the GNU :)

Thanks in advance.
 
Lol, sorry, I forgot to Ctrl-C and Ctrl-V my code... *rolls eyes*

#include <iostream>

using namespace std;
int main() {
cout << &quot;Content-type: text/html\n\n&quot;;
cout << &quot;<html>\n&quot;;
cout << &quot;<body>\n&quot;;
cout << &quot;<h1>Testing!!!</h1>\n&quot;;
cout << &quot;</body>\n&quot;;
cout << &quot;</html>\n&quot;;
return 0;
}
 
>> compile this baby into CGI NOT via compiling to an EXE

The bad news is that CGI stands for Common Gateway Interface not a different form of a binary artifact. In other words a CGI application is an executable by definition.

Sorry this does not help
-pete
 
The only way you can make a C/C++ program work is to complile it into a .exe file. Unlike Perl, C/C++ is not an interpretted language. There's always a better way...
 
I may be a little bias, but learn perl. It's worth your while. I absolutely love the language. Anything that was painful to do in C/C++ is already included and very easy in perl (well...mostly).

The other option is to cheat the system. There's always a way. Figure out how it determines that the file is an .exe and change yours somehow to not be that way.

Well, I lied, there's another way. Can you telnet/ssh into the server and compile it there? Generally if they're nice enough to let you in, there's things to do once you're there. Mine doesn't (curses!) and at least once a month I end up having to do something the long way. If you can get in, just try all the standard command line compiler names (gcc, g++, cl are the only one's I've used). ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
To icrf...

most hosting companies block telnet because of the security issues at hand. Even though most users don't want, or know how, to breach a systems security, I doubt that any of them would want to host their site with a company that does allow telnet. The potential liability wold be too great.

I agree with you about Perl. I, too, am a C man and learning Perl was a very easy task. For the web, Perl is just sooooooo much easier. There's always a better way...
 
Thanks, I'll try to find a way round it.

The main reason why I don't want to learn Perl is I haven't the time or need. I know VB 6 well enough, and also C and C++, so learning Perl is just a pain. Also, its much slower than C++, so why bother to learn it? I won't use it anywhere else anyway.
 
Most comercial hosts provide a cgi_bin folder for executables. Is this a free hosting service or something?

-pete
 
No, I pay for this web hosting. They give the reason as 'security issues'.
 
I'd switch then. Doing CGI dev on Windows/IIS should be as simple as tying your shoes :)

&quot;But, that's just my opinion... I could be wrong&quot;.
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top