Home > Database > Mysql Tutorial > Linux下使用MySQL C API

Linux下使用MySQL C API

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:00:24
Original
1181 people have browsed it

在Linux下面使用MySQL的C API时需要引入相关的库并包含头文件mysql.h。MySQL提供了一个mysql_config脚本,可以通过这个脚本获得编

在Linux下面使用MySQL的C API时需要引入相关的库并包含头文件mysql.h。MySQL提供了一个mysql_config脚本,可以通过这个脚本获得编译时的参数.

如,在我的RHEL 5.4X-64 中执行mysql_config --cflags可得:

#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 -D_FILE_OFFSET_BITS=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

于是,,在编译需要MySQL C API的代码时可以加上 $(mysql_config --cflags) $(mysql_config --libs)来获得相应编译参数和库。如:

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

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template