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)
Useful Links
- fstream
- GET vs. POST
- C++ Web Programming
- String
- Input/Output with files
- dirent.h
- How to get a list of files in a directory
- Best way to trim a string
- string::erase
- string::append
- string::push_back
- strtok
- Can't read from stdin twice
- Howto: Connect MySQL server using C program API under Linux or UNIX
- mysql_fetch_row and other functions on the MySQL site
- Fixed for "undefined symbols" when building in Xcode 6
- Force gcc to compile 32 bit programs on 64 bit platform