Use MySQL c api in Linux

Source: Internet
Author: User

When using MySQL C APIs in Linux, You need to introduce relevant libraries and include the header file mysql. h. MySQL provides a mysql_config script that can be used to obtain the parameters during compilation.

For example, execute mysql_config -- cflags in my RHEL 5.4X-64 to get the following information:

# Mysql_config -- cflags

-I/usr/include/mysql-g-pipe-Wp, -D_FORTIFY_SOURCE = 2-fexceptions-fstack-protector -- param = ssp-buffer-size = 4-m64-D_GNU_SOURCE-Buffers = 64-D_LARGEFILE_SOURCE-fno-strict-aliasing-fwrapv

# Mysql_config -- libs

-Rdynamic-L/usr/lib64/mysql-lmysqlclient-lz-lcrypt-lnsl-lm-L/usr/lib64-lssl-lcrypto

Therefore, you can add $ (mysql_config -- cflags) $ (mysql_config -- libs) to obtain the corresponding compilation parameters and libraries when compiling the code that requires MySQL c api. For example:

Gcc-W-Wall $ (mysql_config -- cflags) test_db_conn.c $ (mysql_config -- libs)-o test_db

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.