centos gcc编译 mysql 问题发现
来源:互联网 发布:php fsockopen post 编辑:程序博客网 时间:2024/04/30 01:41
一点点来:
编译不通过非常郁闷
20.7.16.1. Problems Linking to the MySQL Client Library
When linking with the C API, the following errors may occur on some systems:
gcc -g -o client test.o -L/usr/local/lib/mysql \ -lmysqlclient -lsocket -lnslUndefined first referenced symbol in filefloor /usr/local/lib/mysql/libmysqlclient.a(password.o)ld: fatal: Symbol referencing errors. No output written to client
If this happens on your system, you must include the math library by adding -lm
to the end of the compile/link line.
Linking with the single-threaded library (libmysqlclient
) may lead to linker errors related topthread
symbols. When using the single-threaded library, please compile your client withMYSQL_CLIENT_NO_THREADS
defined. This can be done on the command line by using the-D
option to the compiler, or in your source code before including the MySQL header files. This define should not be used when building for use with the thread-safe client library (libmysqlclient_r
).
When you are linking an application program to use the MySQL client library, you might get undefined reference errors for symbols that start withmysql_
, such as those shown here:
/tmp/ccFKsdPa.o: In function `main':/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
You should be able to solve this problem by adding -Ldir_path -lmysqlclient
at the end of your link command, where dir_path
represents the path name of the directory where the client library is located. To determine the correct directory, try this command:
shell> mysql_config --libs
The output from mysql_config might indicate other libraries that should be specified on the link command as well.
If you get undefined reference
errors for the uncompress
or compress
function, add -lz
to the end of your link command and try again.
If you get undefined reference
errors for a function that should exist on your system, such asconnect
, check the manual page for the function in question to determine which libraries you should add to the link command.
You might get undefined reference
errors such as the following for functions that don't exist on your system:
mf_format.o(.text+0x201): undefined reference to `__lxstat'
This usually means that your MySQL client library was compiled on a system that is not 100% compatible with yours. In this case, you should download the latest MySQL source distribution and compile MySQL yourself. SeeSection 2.17, “Installing MySQL from Source”.
You might get undefined reference errors at runtime when you try to execute a MySQL program. If these errors specify symbols that start withmysql_
or indicate that the mysqlclient
library can't be found, it means that your system can't find the sharedlibmysqlclient.so
library. The fix for this is to tell your system to search for shared libraries where the library is located. Use whichever of the following methods is appropriate for your system:
Add the path to the directory where
libmysqlclient.so
is located to theLD_LIBRARY_PATH
environment variable.Add the path to the directory where
libmysqlclient.so
is located to theLD_LIBRARY
environment variable.Copy
libmysqlclient.so
to some directory that is searched by your system, such as/lib
, and update the shared library information by executingldconfig
.
Another way to solve this problem is by linking your program statically with the-static
option, or by removing the dynamic MySQL libraries before linking your code. Before trying the second method, you should be sure that no other programs are using the dynamic libraries.
部分转自:http://dev.mysql.com/doc/refman/5.0/en/c-api-linking-problems.html
- centos gcc编译 mysql 问题发现
- centos nginx安装问题/gcc编译问题
- CentOS 6.8 安装MySql+GCC 编译
- CentOS编译安装GCC
- centos 下编译 gcc
- CentOS编译安装gcc
- 解决CentOS 5.5下编译gcc 4.5.1问题
- centos 安装gcc编译环境
- centos 下编译GCC
- gcc-7.1-centos-6.9-编译
- gcc编译不容易发现的错误
- Windows GCC 编译 MySQL++
- gcc编译问题
- gcc 编译乱码问题
- gcc 编译问题
- gcc编译问题
- gcc编译问题
- gcc编译c问题
- HDOJ 1874 畅通工程续 (Floyd)
- 备忘:防止jvm吃异常堆栈的参数
- python文件读写2
- STL
- 界面引擎 XML文件格式以及XAR包介绍
- centos gcc编译 mysql 问题发现
- 怎样从内存中获取数据
- 只技术NB,就一定有很好的价值体现吗?刚看了一篇文章,和各位兄弟姐们共勉。
- Hibernate实战之——将大批量数据从excel导入sqlserver
- redhat网络配置
- java调用.net生成的WebService(axis调用)
- BusyBox 版本1.10-2
- 开机后就黑屏显示BOOTMGR image is corrupt. The system cannot boot
- SQL Server ——函数