Home > Database > Mysql Tutorial > body text

运用MySQL C语言API 出错的问题

WBOY
Release: 2016-06-07 16:58:31
Original
852 people have browsed it

(1)出现了找不到 mysql.h这个头文件时, cd /usr/include/mysql/ cp * /usr/include/(2)当出现undefined re

(1)出现了找不到 mysql.h这个头文件时,,
         cd /usr/include/mysql/
         cp * /usr/include/

(2)当出现undefined reference to `mysql_init'等时,
         最好用 #gcc -o test test.c `mysql_config --cflags --libs`
         其它的编译命令: #gcc -o test test.c -I/usr/include/mysql -L/usr/lib/mysql-lmysqlclient -lz -lm
         #gcc -o test test.c -I /usr/include/mysql -L
         /usr/lib/mysql -l mysqlclient -lz -lm

        mysql_config:获取编译客户的编译选项
       mysql_config 提供了关于编译MySQL客户端以及将其连接到MySQL的有用信息.支
       持下列选项:
           --cflags:编译器标志,用于查找包含文件,以及编译libmysqlclient库时所
            要使用的关键编译器标志和定义.
           --include:编译器选项,用于查找MySQL包含文件(注意,正常情况下应使用"--cflags",而不是该选项).
           --libmysql-libs,--enbedded:与MySQL嵌入式服务器进行连接所需的库和选项.
           --libs:与MySQL客户端库进行连接所需要的库和选项.
           --libs_r:与线程安全MySQL客户端进行链接所需的库和选项.
           --port:默认的tcp/ip端口号,配置MySQL时定义.
           --socket:默认的Unix套接字文件,配置MySQL时定义.   
           --version:版本号以及MySQL分发版的版本.
       其中,mysql_config在/usr/bin/mysql_config(这是rpm包安装后的默认目录),
若是源码安装,则一般在..../mysql/bin/mysql_config.

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!