Configure the codeblocks project to use MySQL

Source: Internet
Author: User
   

Knot:

 

 
In order to use MySQL in the C ++ project created under codeblocks, I worked so hard for half an afternoon that I finally breathed a sigh of relief and completed the compilation.


Many of them succeeded in repeated failures several times. A taste of being an individual is only an impulse to make me feel overwhelmed.

However, the problem is still solved after all.

While the unforgettable pain has not vanished, record the process as soon as possible. It takes a few hours to complete the task and is used as a backup.

-----------------------------------------------------

Record:

Configure the C ++ project under codeblocks for MySQL:


Goto project-> build options


A. compiler settings tab-> Other
Options: 'mysql _ config -- cflags'


B. linker settings tab-> Other
Options: 'mysql _ config -- libs'


To get codecompletion you probably need to add the include dir
Your project


C. search directories tab->
Compiler:/usr/include/MySQL

-----------------------------------------------------
Problem:

To understand what mysql_config is?

After mysql_config is used, why is the lmysqlclient Parameter not required?


I found some descriptions of mysql_config with the problem. Reprinted as follows:
-----------------------------------------------------
Reprinted:
// Reprint the statement: the following text comes from: Java getting started training network


#

Mysql_config provides useful information about compiling MySQL clients and connecting them to MySQL.


Mysql_config supports the following options:

?
-- Cflags

The compiler flag is used to find include files and key compiler flags and definitions used to compile the libmysqlclient library.


?
-- Include

Compiler option, used to find MySQL contained files (Note: Normally, use "?" Cflags ).


?
-- Libmysqld-libs, --- embedded

The required libraries and options to connect to the MySQL Embedded Server.

?
-- Libs

The required libraries and options for connecting to the mysql client library.

?
-- Libs_r

The required libraries and options to link with the thread-safe MYSQL client library.

?
-- Port

The default TCP/IP Port number, which is defined when MySQL is configured.

?
-- Socket

The default UNIX socket file, which is defined when MySQL is configured.

?
-- Version

Version and MySQL distribution version.


If mysql_config is called without any options, a list of all options supported by mysql_config and their values are displayed:


Shell> mysql_config
Usage:
/Usr/local/MySQL/bin/mysql_config [Options]

Options:


-- Cflags
[-I/usr/local/MySQL/include/MySQL-mcpu = pentiumpro]


-- Include
[-I/usr/local/MySQL/include/MySQL]


-- Libs
[-L/usr/local/MySQL/lib/MySQL-lmysqlclient-LZ



-Lcrypt-lnsl-lm-L/usr/lib-lssl-lcrypto]


-- Libs_r
[-L/usr/local/MySQL/lib/MySQL-lmysqlclient_r



-Lpthread-LZ-lcrypt-lnsl-lm-lpthread]


-- Socket
[/Tmp/MySQL. Sock]


-- Port
[3306]


-- Version
[4.0.16]

-- Libmysqld-libs
[-L/usr/local/MySQL/lib/MySQL-lmysqld-lpthread-LZ



-Lcrypt-lnsl-lm-lpthread-LRT]


You can use mysql_config on the command line and include values for specific options. For example, to compile a mysql client program,


You can use mysql_config, as shown in the following example:

Shell>
CFG =/usr/local/MySQL/bin/mysql_config

Shell> Sh-c "gcc-O progname
'$ Cfg -- cflags' progname. c' $ cfg -- libs '"

When using mysql_config in this way, you must call it within the character.

In this way, the shell can be notified to execute it, and its output can be substituted into the Environment command.

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.