Advertise here: Contact FM.


How to create a CGI program with Visuall C++ Express Edition?
December 6, 2006 8:09 PM   RSS feed for this thread 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 (12 comments 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


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


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


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


Visual Studio .NET 2003 (7.1) doesn't have a CGI project type, and I doubt 7.0 did either, since 7.1 is mostly just bugfixes, and maybe a later version of the CLR and associated .NET libraries.

VS 6 came from the era when Microsoft was still fairly internet-agnostic, so I would be surprised if it had a CGI project type.

More likely, you are either remembering a different TLA, or you had a 3rd party CGI wizard. There are tons of random Visual Studio wizards out there.

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.

Try GCC, the standard unix-like C/C++ ccompiler.
posted by b1tr0t 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


Looks like IIS supports CGI and ISAPI.
posted by b1tr0t at 11:54 PM on December 6, 2006


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


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.

Does it not support static linking, or just not include the static versions of the C Runtime library?

Also, what is wrong with just copying the DLLs over to the webserver.

Finally, try GCC.
posted by b1tr0t at 9:03 PM on December 8, 2006


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 What's my role in the free/lib...   |   I am trying to recreate a phot... Newer »
This thread is closed to new comments.