/usr/bin/ld: cannot find -lmysqlclient


環境centos 5.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/lib 64/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  

 
の最後の部分
エラーメッセージをもう一度よく確認してください.