且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

/usr/bin/ld: cannot find -lmysqlclien

更新时间:2022-10-01 15:22:01

环境 
centos5.7 x86_64 系统上安装postfix !

 

错误

"/usr/bin/ld: cannot find -lmysqlclient"

类似/usr/bin/ld: cannot find -xxxx的错误有很多,

最简单的判断一下:是否安装相应的mysql-devel包

发现mysql-devel 包已经安装了


  1. # rpm -qa | grep mysql 
  2. mysql-devel-5.0.77-4.el5_6.6 
  3. mysql-server-5.0.77-4.el5_6.6 
  4. mysql-devel-5.0.77-4.el5_6.6 
  5. mysql-5.0.77-4.el5_6.6 
  6. php-mysql-5.1.6-27.el5_5.3 
  7. mysql-5.0.77-4.el5_6.6 

 

 

仔细再次查看错误信息,发现都是 /usr/lib/mysql/


  1. [postfix-2.6.13]$ make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl -lcrypto' 
  2.  
  3. /usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient 
  4. /usr/bin/ld: cannot find -lmysqlclient 
  5. collect2: ld returned 1 exit status 
  6. make: *** [master] Error 1 
  7. make: *** [update] Error 1 
  8.  
  9. [postfix-2.6.13]$ cat conf/makedefs.out  
  10. # Do not edit -- this file documents how Postfix was built for your machine. 
  11. SYSTYPE = LINUX2 
  12. AR  = ar 
  13. ARFL    = rv 
  14. RANLIB  = ranlib 
  15. SYSLIBS = -L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2  -lssl -lcrypto -ldb -lnsl -lresolv 
  16. CC  = gcc $(WARN) -DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS  
  17. OPT = -O 
  18. DEBUG   = -g 
  19. AWK = awk 
  20. STRCASE =  
  21. EXPORT  = AUXLIBS='-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2  -lssl -lcrypto' CCARGS='-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' OPT='-O' DEBUG='-g' 
  22. WARN    = -Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \ 
  23.     -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \ 
  24.     -Wunused -Wno-missing-braces 

 

解决方法,指定为/usr/lib64/mysql


  1. [postfix-2.6.13]$ make clea 
  2.  
  3. [postfix-2.6.13]$ make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl -lcrypto' 
  4.  
  5. [postfix-2.6.13]$ cat conf/makedefs.out  
  6. # Do not edit -- this file documents how Postfix was built for your machine. 
  7. SYSTYPE = LINUX2 
  8. AR  = ar 
  9. ARFL    = rv 
  10. RANLIB  = ranlib 
  11. SYSLIBS = -L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2  -lssl -lcrypto -ldb -lnsl -lresolv 
  12. CC  = gcc $(WARN) -DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS  
  13. OPT = -O 
  14. DEBUG   = -g 
  15. AWK = awk 
  16. STRCASE =  
  17. EXPORT  = AUXLIBS='-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2  -lssl -lcrypto' CCARGS='-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' OPT='-O' DEBUG='-g' 
  18. WARN    = -Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \ 
  19.     -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \ 
  20.     -Wunused -Wno-missing-braces 
  21.  
  22. make && make isntall  
本文转自 dongnan 51CTO博客,原文链接:
http://blog.51cto.com/dngood/744748