Mysql C Programming in linux

Source: Internet
Author: User
In the linux environment, mysql C Programming starts-Linux general technology-Linux programming and kernel information. The following is a detailed description. My environment is debian 2.6.x

First install the required development kit

Sudo apt-get install gcc g ++ libgpc3 libg ++ make gdb

Install mysql c Language Development Kit

Sudo apt-get install libmysql ++-dev libmysql ++ 2 c2a libmysqlclient15-dev libmysqlclient15off

Copy the lib file to the public

Sudo cp/usr/lib/mysql/*/usr/lib/

Create a new file test. cpp

Vim test. cpp

Input content

# Include
# Include
# Include "/usr/include/mysql. h"

Int main (){
MYSQL mysql;
Mysql_init (& mysql );
}

Ctrl + O save ctrl + x and exit.

Then compile

G ++-lmysqlclient test. cpp-o test

Run

./Test

If there is no prompt or error, it means the operation is successful.

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.