環境
centos5.7 x86_64 系統上安裝postfix !
錯誤
"/usr/bin/ld: cannot find -lmysqlclient"
類似/usr/bin/ld: cannot find -xxxx的錯誤有很多,
最簡單的判斷一下:是否安裝相應的mysql-devel包
發現mysql-devel 包已經安裝了
# rpm -qa | grep mysql
mysql-devel-5.0.77-4.el5_6.6
mysql-server-5.0.77-4.el5_6.6
mysql-5.0.77-4.el5_6.6
php-mysql-5.1.6-27.el5_5.3
仔細再次檢視錯誤資訊,發現都是 /usr/lib/mysql/
[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'
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [master] Error 1
make: *** [update] Error 1
[postfix-2.6.13]$ cat conf/makedefs.out
# Do not edit -- this file documents how Postfix was built for your machine.
SYSTYPE = LINUX2
AR = ar
ARFL = rv
RANLIB = ranlib
SYSLIBS = -L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto -ldb -lnsl -lresolv
CC = gcc $(WARN) -DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS
OPT = -O
DEBUG = -g
AWK = awk
STRCASE =
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'
WARN = -Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \
-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
-Wunused -Wno-missing-braces
解決方法,指定為/usr/lib64/mysql
[postfix-2.6.13]$ make clea
[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'
SYSLIBS = -L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto -ldb -lnsl -lresolv
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'
make && make isntall
本文轉自 dongnan 51CTO部落格,原文連結:
http://blog.51cto.com/dngood/744748