The Polyglot Web

Web Coding in C++

C++ is a compiled language. I give the compiled files the cgi file extension. I compile the files using this script, which I call makp:

g++ -ansi -g -o $1.cgi $1.cpp

This script compiles the cpp file and ouputs it to a cgi file with the same base filename. The code runs from the cgi file, which has execute permissions. The cpp code file remains in the directory, so we can view the source code. The script is invoked as follows (for example). Note that you don't specify the file extension. It assumes that the source file has the cpp extension and the object code file will have the cgi extension.

./makp table

There is also a script makeall.csh that compiles all the C++ files in a foreach loop. This script is invoked as follows. It compiles any C++ files it finds in this directory. Some of the files (may) generate errors because they are not finished yet.

./makeall.csh

I had a lot of problems trying to install and use the MySQL Connector/C. Instead, I followed the instructions on this site and changed my compile script as they suggested:

g++ $(mysql_config --cflags) -m32 -ansi -g -o $1.cgi $1.cpp $(mysql_config --libs)