Accessing a MySQL Database from a C++ CGI Program
If you want to access a MySQL database through CGI, C++ is a great option. Sure, you can use other languages such as PHP or Perlbut although these other languages might be easy to use, C++ has the advantage of being fast, powerful, and fully compiled, thereby hiding your original code. In this article, I show you how you can write CGI programs in C++ that can access a MySQL database.
Tools I Used
To access a MySQL database from C++, I used the MySQL Connector/C++, also known as MySQL++. (There are actually other C++/MySQL libraries available as well, which probably work fine; however, this is the one actually built by the MySQL people.) The MySQL++ library includes a set of classes that allow easy access to MySQL.
TIP
You can find the (free!) MySQL++ library at http://www.mysql.com/products/mysql++/index.html. The online docs are at http://www.mysql.com/documentation/mysql++/index.html.
For the CGI portion of your program, you can do without a CGI library, but using one can make your life a lot easier. I looked on the Web and discovered many CGI libraries for C++. The one I settled on is the official GNU library, called cgicc. You can find it at http://www.cgicc.org.
The Web sites for these libraries include information on downloading, building, and installing the two libraries.