当前位置: 技术问答>linux和unix
Linux mysql 问题
来源: 互联网 发布时间:2016-07-22
本文导语: bash-2.05b# gcc -o oo oo.c -I /usr/local/mysql/include -L /usr/local/mysql/lib /tmp/ccEQAkDG.o(.text+0x1f): In function `main': : undefined reference to `SQLAllocHandle' /tmp/ccEQAkDG.o(.text+0x58): In function `main': : undefined reference to `SQLSetEnvAttr' /tm...
bash-2.05b# gcc -o oo oo.c -I /usr/local/mysql/include -L /usr/local/mysql/lib
/tmp/ccEQAkDG.o(.text+0x1f): In function `main':
: undefined reference to `SQLAllocHandle'
/tmp/ccEQAkDG.o(.text+0x58): In function `main':
: undefined reference to `SQLSetEnvAttr'
/tmp/ccEQAkDG.o(.text+0x88): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0xa1): In function `main':
: undefined reference to `SQLAllocHandle'
/tmp/ccEQAkDG.o(.text+0xd4): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0xea): In function `main':
: undefined reference to `SQLSetConnectAttr'
/tmp/ccEQAkDG.o(.text+0x10d): In function `main':
: undefined reference to `SQLConnect'
/tmp/ccEQAkDG.o(.text+0x154): In function `main':
: undefined reference to `SQLGetDiagRec'
/tmp/ccEQAkDG.o(.text+0x17e): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x1aa): In function `main':
: undefined reference to `SQLAllocHandle'
/tmp/ccEQAkDG.o(.text+0x1f1): In function `main':
: undefined reference to `SQLGetDiagRec'
/tmp/ccEQAkDG.o(.text+0x21b): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x245): In function `main':
: undefined reference to `SQLBindCol'
/tmp/ccEQAkDG.o(.text+0x267): In function `main':
: undefined reference to `SQLBindCol'
/tmp/ccEQAkDG.o(.text+0x27f): In function `main':
: undefined reference to `SQLExecDirect'
/tmp/ccEQAkDG.o(.text+0x2ce): In function `main':
: undefined reference to `SQLGetDiagRec'
/tmp/ccEQAkDG.o(.text+0x2fb): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x30b): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x31b): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x335): In function `main':
: undefined reference to `SQLNumResultCols'
/tmp/ccEQAkDG.o(.text+0x358): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x366): In function `main':
: undefined reference to `SQLDisconnect'
/tmp/ccEQAkDG.o(.text+0x376): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x386): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x3b5): In function `main':
: undefined reference to `SQLRowCount'
/tmp/ccEQAkDG.o(.text+0x3eb): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x3f9): In function `main':
: undefined reference to `SQLDisconnect'
/tmp/ccEQAkDG.o(.text+0x409): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x419): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x442): In function `main':
: undefined reference to `SQLFetch'
/tmp/ccEQAkDG.o(.text+0x479): In function `main':
: undefined reference to `SQLFetch'
/tmp/ccEQAkDG.o(.text+0x492): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x4a0): In function `main':
: undefined reference to `SQLDisconnect'
/tmp/ccEQAkDG.o(.text+0x4b0): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x4c0): In function `main':
: undefined reference to `SQLFreeHandle'
collect2: ld returned 1 exit status
//////////////////////////////////////////////////////////////////////////
mysql装好了,可以建库,可以用ODBC连,
头文件里也有这些函数,
我应该怎么办?
/tmp/ccEQAkDG.o(.text+0x1f): In function `main':
: undefined reference to `SQLAllocHandle'
/tmp/ccEQAkDG.o(.text+0x58): In function `main':
: undefined reference to `SQLSetEnvAttr'
/tmp/ccEQAkDG.o(.text+0x88): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0xa1): In function `main':
: undefined reference to `SQLAllocHandle'
/tmp/ccEQAkDG.o(.text+0xd4): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0xea): In function `main':
: undefined reference to `SQLSetConnectAttr'
/tmp/ccEQAkDG.o(.text+0x10d): In function `main':
: undefined reference to `SQLConnect'
/tmp/ccEQAkDG.o(.text+0x154): In function `main':
: undefined reference to `SQLGetDiagRec'
/tmp/ccEQAkDG.o(.text+0x17e): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x1aa): In function `main':
: undefined reference to `SQLAllocHandle'
/tmp/ccEQAkDG.o(.text+0x1f1): In function `main':
: undefined reference to `SQLGetDiagRec'
/tmp/ccEQAkDG.o(.text+0x21b): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x245): In function `main':
: undefined reference to `SQLBindCol'
/tmp/ccEQAkDG.o(.text+0x267): In function `main':
: undefined reference to `SQLBindCol'
/tmp/ccEQAkDG.o(.text+0x27f): In function `main':
: undefined reference to `SQLExecDirect'
/tmp/ccEQAkDG.o(.text+0x2ce): In function `main':
: undefined reference to `SQLGetDiagRec'
/tmp/ccEQAkDG.o(.text+0x2fb): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x30b): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x31b): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x335): In function `main':
: undefined reference to `SQLNumResultCols'
/tmp/ccEQAkDG.o(.text+0x358): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x366): In function `main':
: undefined reference to `SQLDisconnect'
/tmp/ccEQAkDG.o(.text+0x376): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x386): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x3b5): In function `main':
: undefined reference to `SQLRowCount'
/tmp/ccEQAkDG.o(.text+0x3eb): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x3f9): In function `main':
: undefined reference to `SQLDisconnect'
/tmp/ccEQAkDG.o(.text+0x409): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x419): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x442): In function `main':
: undefined reference to `SQLFetch'
/tmp/ccEQAkDG.o(.text+0x479): In function `main':
: undefined reference to `SQLFetch'
/tmp/ccEQAkDG.o(.text+0x492): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x4a0): In function `main':
: undefined reference to `SQLDisconnect'
/tmp/ccEQAkDG.o(.text+0x4b0): In function `main':
: undefined reference to `SQLFreeHandle'
/tmp/ccEQAkDG.o(.text+0x4c0): In function `main':
: undefined reference to `SQLFreeHandle'
collect2: ld returned 1 exit status
//////////////////////////////////////////////////////////////////////////
mysql装好了,可以建库,可以用ODBC连,
头文件里也有这些函数,
我应该怎么办?
|
-libmysqlclient就是你要使用的mysql库啊,如果要使用mysql的api就必须连接这个库。
libmysqlclient*.so是动态库,libmysqlclient.a是静态库。
libmysqlclient*.so是动态库,libmysqlclient.a是静态库。
|
错误显示是链接时没有链接库文件,所以你要要把库连接进来,至于库的路径以及名称,是你自己安装的时候设置的,可以通过whereis mysql 看看。
|
/usr/lib/libName.so
引用 时候是 -lName
这是标准 的,
还有自己规定的 ,就是-I
引用 时候是 -lName
这是标准 的,
还有自己规定的 ,就是-I
|
编译加上`mysql_config --libs` `mysql_config --cflags`