Windows DEV-C ++ compile MySQL ++ (key reference)

Source: Internet
Author: User

ArticleSource:Http://blog.csdn.net/likelynn/archive/2007/10/15/1825381.aspx

  1. Download mysql1_2.2.3.tr.gz and decompress it to D: \ mysql ++ 2.2.3
  2. InstallMysql5. 0 server, because it is required during MySQL ++ compilation, You can also download the free installation version on the official website and decompress it to c :\Mysql5. 0
  3. Search for dlltool.exe in the installation path of DEV-C ++ to copy it to c :\Mysql5Under. 0 \ Lib \ OPT
  4. Copy libmysqlclient. Def from D: \ mysql ++ 2.2.3 to c :\Mysql5Under. 0 \ Lib \ OPT
  5. In the command line, enter c: \ mysql5.0 \ Lib \ OPT and execute dlltool-K-d c: \ mysql ++ \ libmysqlclient. def-l libmysqlclient. a. This will generate libmysqlclient. file a (dlltool error, unknown reason)
  6. Copy libmysqlclient. A to D: \ mysql ++ 2.2.3.
  7. Open it under D: \ mysql ++ 2.2.3Makefile. Mingw, replace the path c: \ Program Files \ mysql \ MySQL Server 5.0 with the local c :\Mysql5. 0 path
  8. Open MySQL ++. BKL under D: \ mysql ++ 2.2.3 and replace the path c: \ Program Files \ mysql \ MySQL Server 5.0 with the local c :\Mysql5. 0 path
  9. In the command line, enter D: \ mysql ++ 2.2.3 and execute: mingw32-make-F makefile. mingw
  10. After step 2 is successful, run install. Bat install on the console to create the c: \ mysql ++ directory.CodeRequired directory
  11. Create a folder lib under c: \ mysql ++, and set libmysqlclient under D: \ mysql ++ 2.2.3. def, libmysqlclient. a, mysqlpp. DLL, libmysqlpp. a, libmysqlpp_util.a copy to lib
  12. In C :\Mysql5In. 0 \ Lib \ opt, find libmysql. dll, libmysql. Lib, copy it to Lib, or include
  13. Set c :\Mysql5Copy all header files under. 0 \ include to D: \ mysql ++ 2.2.3 \ include, or later include files in the project
  14. Create a project with DEV-C ++, add c: \ mysql ++ to the project's inclusion path, and add files under c: \ mysql ++ \ Lib in the parameter-connector
  15. Add include <MySQL ++. h> and using namespace mysqlpp to the project header file, copy libmysql. dll and mysqlpp. DLL to the project directory, and compile the file successfully!

 

Code:

# Include <cstdlib>
# Include <iostream>
# Include <MySQL ++. h>

Using namespace STD;
Using namespace mysqlpp;

Int main (INT argc, char * argv [])
{
Connection con = new connection ();

// Create a database connection. The parameters are dbname, svcip, username, and password.
Con. Connect ("collagen", "192.168.0.221 ","*****","*******");

If (! Con)
{
Cout <"Connect failed ~! "<Endl;
}
Else
{
Cout <"Oh. Year ~! "<Endl;
Cout <con. client_info () <Endl; // display client information
Cout <con. host_info () <Endl; // The Connected Server and the protocol used
Cout <con. server_info () <Endl; // Display Server Information
Cout <con. Stat () <Endl; // current server status
}

System ("pause ");

Return exit_success;

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.