gcc编译c语言调用mysql存储过程代码出现的问题list

来源:互联网 发布:益盟软件怎样 编辑:程序博客网 时间:2024/04/29 01:21
1.问题:mysql.c:1:19: 错误:mysql/mysql.h:没有那个文件或目录
结局:

原因:没有装 mysql-devel-5.0.22-2.1.i386.rpm

[root@localhost RPMS]#yum install mysql-devel

2.问题:/tmp/ccyHfsX2.o(.text+0x1e): In function `main':
: undefined reference to `mysql_init'
/tmp/ccyHfsX2.o(.text+0x47): In function `main':
: undefined reference to `mysql_real_connect'
/tmp/ccyHfsX2.o(.text+0x76): In function `main':
: undefined reference to `mysql_query'
/tmp/ccyHfsX2.o(.text+0x9a): In function `main':
: undefined reference to `mysql_affected_rows'
/tmp/ccyHfsX2.o(.text+0xbc): In function `main':
: undefined reference to `mysql_error'
/tmp/ccyHfsX2.o(.text+0xcf): In function `main':
: undefined reference to `mysql_errno'
/tmp/ccyHfsX2.o(.text+0xf5): In function `main':
: undefined reference to `mysql_close'
/tmp/ccyHfsX2.o(.text+0x11f): In function `main':
: undefined reference to `mysql_errno'
/tmp/ccyHfsX2.o(.text+0x135): In function `main':
: undefined reference to `mysql_error'
/tmp/ccyHfsX2.o(.text+0x148): In function `main':
: undefined reference to `mysql_errno'
collect2: ld returned 1 exit status
结局:在gcc最后加上-I/usr/include/mysql/ -L/usr/lib/mysql/ `mysql_config --cflags --libs`这句话。
例如:[root@zieckey mysql]# gcc -o insert insert.c -I/usr/include/mysql/ -L/usr/lib/mysql/ `mysql_config --cflags --libs`

3.问题:安装了mysql后在启动service mysql start时显示unrecognized service。

结局:装一个mysql-server就可以了。我是直接yum install mysql-server