10 Years
Discussion Span
Last Post by VernonDozier

I'm not sure what configuration tricks you'll need to perform to get this to work on Windows + XAMPP, but, the following looks 'wrong':

- your href in the HTML goes to a local file, this certainly wont work. You'll need to move the compiled C++ application into the folder which XAMPP maps to, and change the link to href="".
- It is possibly the case that the C++ app will have to go into the cgi-bin folder, I haven't used XAMPP for a long time, and cant remember how it deals with executables and permissions.. read the XAMPP docs if in doubt.
- The program will not work properly as a CGI script because it's not sending an HTTP header. Change to the following ( although the program should work [ as in write to the file ] if you set everything up properly, it will display an Error 500 if you do not make this change ):

// Filename        : HelloWorld.cpp
// Executable Name : HelloWorld.exe
#include <fstream>
#include <iostream>
using namespace std;
int main (int argc, char* argv[])
    cout << "Content-Type:text/html;charset=iso-8859-1\n\n";
    ofstream outs;
    outs.open ("HelloWorld.txt");
    outs << "Hello World" << endl;
    return 0;

Don't worry about security right now ( but certainly read up about it when you get the time ). XAMPP doesn't make your computer a public server with the default settings, and nobody but you can access and see your files, if I go to it will send me to any server program on my PC ( I don't have one running, but it would if I had Apache on ).


Thank you for replying. I've been fiddling around with it. It seems to be looking in the current directory (as opposed to the cgi-bin directory). It finds HelloWorld.exe now, but doesn't seem to realize I am trying to execute it and it offers to let me save it. Seems like it thinks it is a text file or something. I changed the link to a perl file that came with xampp. It displayed (but did not run) that program to the screen, but still looked for the one in the local directory. When I switched to a link with a .cgi suffix, it appears to have looked in the cgi-bin directory and actually ran it. It was set up to print information in html and it did that. However, it didn't print the word "print" but rather the contents inside the quotes, so I'm guessing that one worked correctly. It seems like the suffix of the file is important as far as xampp knowing what to do with it? There must be a list of file extensions somewhere where I need to specify that I want".exe" to run? Still experimenting around with this. Thank you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.