1.添加mysql的头文件
MYSQLINC = /usr/local/mysql/include
或
MYSQLINC = /usr/local/mysql
2.添加mysql的依赖库
#find / -name "libmysqlclient*" // 查找mysql lib的目录
MYSQLLIB = -L /usr/lib64/mysql -lmysqlclient -lz -lm
3.g++编译时添加 INC 与 MYSQLLIB 的支持
4.如果做了上述步骤仍然提示如下错误:
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [bin/DBServer] Error 1
解决:
ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/libmysqlclient.so
时间: 2024-10-28 21:40:37