How to create a CGI program with Visuall C++ Express Edition?
December 6, 2006 8:09 PM   Subscribe

Is it possible to use Microsoft Visual C++ Express Edition to create a CGI program to run under IIS?

I haven't done computer programming professionally for 5+ years, but I do work on my own web-based application to support the business I run.

Most of my application is Active Server Pages (VBScript and JavaScript), except for one CGI program written in C.

Until recently I had a copy of Visual Studio 6.0 (for which I didn't have the installation discs..) on my notebook computer. The hard drive died, and while I did have backups of all my source code, I did not have backups for the Visual C++ project configuration file(s) for the CGI program.

So, what I've got now is the C source file, and a downloaded copy of the free Express Edition of Visual C++. My problem is that I can't figure out how to recompile my C application to make it work as a CGI program.

I don't want to purchase the full Visual Studio suite just to compile this single program. If the Express Edition won't work, I would be interested in any other free compiler that will work. In fact, I'd prefer a simple command line compiler, if any exist.
posted by JeffL to Computers & Internet (9 answers total)
 
A CGI program is a normal program that just behaves in a certain way (reads stuff from standard input/writes stuff to standard output). Looking at the Express FAQ, I don't see why you can't just compile your executable and be on your merry way.

Now, the major difference (for you) between the Express and the normal editions is that Express doesn't come with all the library support. For example, MFC, ATL, .NET 1.0, and so on. This might be a problem, it might not. Hard to say until you start getting compile errors.
posted by sbutler at 8:30 PM on December 6, 2006


Response by poster: With Visual Studio you could actually choose a project type of CGI (I think - it's been a while), whereas with the Express Edition the only choice that seems to make sense is "Win32 Console Application".

When I create a new project of that type and add my C source file to the project, it does compile ok; it just doesn't run under IIS. I get an unhelpful (so far), non-specific error message.
posted by JeffL at 8:49 PM on December 6, 2006


What's the error message?
posted by sbutler at 8:59 PM on December 6, 2006


Response by poster: It's a generic message:

The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

I checked the event logs; nothing there.

I can run the program from the command line, but it doesn't work under IID
posted by JeffL at 9:18 PM on December 6, 2006


Response by poster: "IID" should have been IIS, of course...
posted by JeffL at 9:22 PM on December 6, 2006


What happens when you run it from the command line? What output does it give (specifically, is it sending the headers properly)?
posted by sbutler at 9:38 PM on December 6, 2006


Are you sure you're talking about a CGI program instead of something MS-specific? Does it have a normal main function and write to stdout? If so, there could still be plenty of reasons why it's not running on your IIS (can't find DLLs, for example).
posted by themel at 11:20 PM on December 6, 2006


Response by poster: The problem appears to be that the Express Edition does not allow static linking, so the CGI exe won't work unless its dependencies are also copied to the web server.

So far, googling leads me to believe that the only solution is to upgrade to the non-free version of Visual Studio (or use a non Microsoft compiler).
posted by JeffL at 7:33 PM on December 8, 2006


Response by poster: I decided to use the now-free Watcom C Compiler. It works fine.
posted by JeffL at 8:08 AM on December 11, 2006


« Older I'm FLOSSing everyday   |   Help me recreate the past for christmas. Newer »
This thread is closed to new comments.