Recently looking at the database development of things, because in C + +, so just look at mysql++.
MySQL provides the C language of the API, there are some other languages connector, although previously also written in the C language MySQL connection, adding and removing changes and other things, but all feel too toys, recently see new projects, the database package is based on mysql++, so the way to learn.
mysql++ is a package for the MySQL C API, for C + + developers to provide the same as the operation of the STL container as easy as the operation of the database mechanism, simply speaking, is to support the C + + of those "tall" mechanism of the chant. So it's easy to use it in C + +. The heartbeat is inferior to the action, install a try.
With mysql++ development of the first step, of course, you have to have a database program, how to install MySQL here is not much to say.
Then, go to mysql++ website Next Library source code, the latest version is 3.2.1. and unzip it.
Tar-xvzf mysql++-3.2.1.tar.gz
Into the unpacked directory, a lot of files, conventions------First read the Readme, because my is Ubuntu, so I see Readme-linux.txt
First it tells you that mysql++ must have MySQL C API to work properly, MySQL C API will need to install mysqlclient.
Under Ubuntu, execute the following command to
sudo apt-get install Libmysqlclient-dev
Second it tells you, in order to prevent the dynamic linker can not find, it is best not to install in the non-mainstream directory, it is recommended that you put/usr below
./configure--PREFIX=/USR
Executes the recommended command, it starts to detect the file and configures it.
And then... On the gorgeous Li's error. - -!
It says it's not looking for mysqlclient. Locate, determine if the installation
If you can't find it, you can tell it where it's put.
./configure--PREFIX=/USR--with-mysql-lib=/usr/lib/x86_64-linux-gnu
That's good enough. Then make. Make install (if you don't have enough permissions, sudo make install). Done, the installation is successful!
Go to Example to find an example of the test under the Bai ~
The test must first have a database, execute the installation directory
./resetdb-s 127.0.0.1-u [user]-p [Password]
Yes, if you are installing in a non-mainstream directory, then execute it through a script
./exrun./resetdb-s 127.0.0.1-u [user]-p [Password]
If the prompt does not have permission or the user does not exist, then go to the database to add users, to the rights (the user is best to be your login user, password is best empty)
Mysql-uroot-p[password]
Root login mysql, add new user Comoon, password is empty
Insert into Mysql.user (Host,user, Password) VALUES ("%", "Comoon", "" ");
Give permission (test database is Mysql_cpp_data)
Grant all privileges the mysql_cpp_data.* to [e-mail protected] identified by ';
Refresh Permissions
Flush privileges;
Execute the script that generated the test database again, OK.
Enter example directory, compile Simple1, find header file not found
Locate, found here
Plus the include path to try again, found another one not found. Then Add.
g++-o test simple1.cpp-i/usr/include/mysql++/-I/USR/INCLUDE/MYSQL-LMYSQLPP
Finally done.
Executes the program and runs successfully. Print the query results.
More can view mysql++ user manual. Address: http://tangentsoft.net/mysql++/doc/html/userman/
Friendly tip: If you are stubborn to choose to install into a non-mainstream directory, your dynamic linker may not find the shared library files, you need to copy your installation directory libmysqlpp.so.3.2.1 and connection libmysqlpp.so.3 to/usr/local/lib or /usr/lib below and then execute sudo ldconfig. So the linker can find it.
mysql++ Learning (a)------MySQL compilation installation