linux 下使用c语言访问mysqlclient

locate -r mysqlcli

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient.a

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient.so

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient.so.18

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient.so.18.1.0

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient_r.a

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient_r.so

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient_r.so.18

/root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/lib/libmysqlclient_r.so.18.1.0

/usr/local/mysql/lib/libmysqlclient.a

/usr/local/mysql/lib/libmysqlclient.so

/usr/local/mysql/lib/libmysqlclient.so.20

/usr/local/mysql/lib/libmysqlclient.so.20.3.5

/usr/local/mysql/lib/pkgconfig/mysqlclient.pc



/# find . -name mysql.h
./root/sh-1.5.5/mysql/mysql-5.6.21-linux-glibc2.5-x86_64/include/mysql.h
./usr/local/mysql/include/mysql.h


通过两条指令发现  mysql的头文件都在usr local  mysql 的目录下,事先需要安装 apt-get-install mysql-client

那么在makefile 下加链接

LIBS += -L/usr/local/mysql/lib/ -lz   
LIBS += -lmysqlclient  


这里没有加-i头文件 但编译没出错。

sitemap