Aix

ldd:在 AIX 上找不到用於 xl c 編譯二進製文件的庫,但可以找到用於 gcc 編譯二進製文件的庫

  • January 3, 2014

我在 AIX 上編譯了兩個版本的 proftpd,一個gcc和一個xl c compiler來自 IBM 的版本。

編譯兩個版本的命令行幾乎相同,但是當我lddgcc版本上執行時,我沒有問題,而當我嘗試ldd編譯 xl時,我收到libmysqlclient.a消息:

Cannot find libmysqlclient.a(libmysqlclient.so.16)

雖然我確實包含了庫期間的正確路徑彙編。

所以問題是如何辨識二進製文件查找二進製文件的路徑,或者如何在編譯期間包含此路徑?

隨時詢問更多細節,我會更新我的問題。

編輯 1 ldd 結果:

對於我擁有的 gcc 版本:

ldd/usr/local/proftpd/sbin/proftpd
/usr/local/proftpd/sbin/proftpd needs:
   /usr/lib//libc.a(shr.o)
   /opt/freeware/lib/libcrypto.a(libcrypto.so.1.0.1)
   /usr/lib//libpam.a(shr.o)
   /opt/freeware/lib/libssl.a(libssl.so.1.0.1)
   /opt/freeware/lib/mysql/mysql//libmysqlclient.a(libmysqlclient.so.16)
   /opt/freeware/lib/libz.a(libz.so.1)
   /unix
   /usr/lib//libcrypt.a(shr.o)
   /usr/lib//libc.a(shr_64.o)
   /usr/lib//libpthreads.a(shr_xpg5_64.o)
   /usr/lib//libmls.a(shr.o)
   /opt/freeware/lib/libgcc_s.a(shr.o)
   /usr/lib//libpthread.a(shr_xpg5.o)
   /usr/lib//libcrypt.a(shr_64.o)
   /usr/lib//libpthreads.a(shr_xpg5.o)
   /usr/lib//libmlsenc.a(shr.o)
   /usr/lib//libodm.a(shr.o)
   /usr/lib//libpthreads.a(shr_comm.o)

對於 xl C 版本,我有:

ldd proftpd-1.3.4d/proftpd
proftpd-1.3.4d/proftpd needs:
   /usr/lib/libc.a(shr.o)
   /opt/freeware/lib/libcrypto.a(libcrypto.so.1.0.1)
   /usr/lib/libpam.a(shr.o)
   /opt/freeware/lib/libssl.a(libssl.so.1.0.1)
   Cannot find libmysqlclient.a(libmysqlclient.so.16)
   /opt/freeware/lib/libz.a(libz.so.1)
   /unix
   /usr/lib/libcrypt.a(shr.o)
   /usr/lib/libc.a(shr_64.o)
   /usr/lib/libpthreads.a(shr_xpg5_64.o)
   /usr/lib/libmls.a(shr.o)
   /usr/lib/libcrypt.a(shr_64.o)
   /usr/lib/libpthreads.a(shr_xpg5.o)
   /usr/lib/libmlsenc.a(shr.o)
   /usr/lib/libodm.a(shr.o)
   /usr/lib/libpthreads.a(shr_comm.o)

編輯 2+1編譯命令(稍微格式化以使其更具可讀性:

To compile with XL CI use this script

export CONFIG_SHELL=/opt/freeware/bin/bash
export CONFIG_ENV_ARGS=/opt/freeware/bin/bash
export CC=cc
export CFLAGS="-qmaxmem=16384 -DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_ALL_SOURCE -DFUNCPROTO=15 -O -I/opt/freeware/include"export CXX=xlC
export CXXFLAGS=$CFLAGS
export F77=xlf
export FFLAGS="-qmaxmem=16384 -O -I/opt/freeware/include"
export LD=ld
export LDFLAGS="-L/opt/freeware/lib64 -L/opt/freeware/lib:/opt/freeware/lib/mysql/mysql -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000"
export PATH=/usr/bin:/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/vac/bin:/usr/vacpp/bin:/usr/ccs/bin:/usr/dt/bin:/usr/opt/perl5/bin:/opt/freeware/bin:/opt/freeware/sbin:/usr/local/bin:/usr/lib/instl
make clean
./configure 
   --with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql 
   --without-getopt 
   --enable-openssl 
   --with-includes=/home/user/include3_mysql/zlib:/home/user/include_mysql/mysql:/opt/freeware/lib/mysql/mysql 
   #with or without it doesn't work
    --with-libraries=/opt/freeware/lib/mysql/mysql  
    --prefix=/local/proftpd
make

GCC 的命令行有點長,但沒有所有導出部分:

make clean
./configure 
   --with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql 
   --without-getopt 
   --enable-openssl 
   --with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/user/libmath_header/ 
   --with-libraries=/usr/lib/libc.a:/opt/freeware/lib/libcrypto.a:/usr/lib/libpam.a:/opt/freeware/lib/libssl.a:/opt/freeware/lib/mysql/mysql//libmysqlclient.a:/opt/freeware/lib/libz.a:/unix:/usr/lib/libcrypt.a:/usr/lib/libc.a:/usr/lib/libpthreads.a:/usr/lib/libmls.a:/opt/freeware/lib/libgcc_s.a:/usr/lib/libpthread.a:/usr/lib/libcrypt.a:/usr/lib/libpthreads.a:/usr/lib/libmlsenc.a:/usr/lib/libodm.a:/usr/lib/libpthreads.a 
   --prefix=/home/user/proftpd_bin
make

編輯 4:有人有什麼小線索嗎?

我終於使用這個腳本來允許編譯:

export CONFIG_SHELL=/opt/freeware/bin/bash
export CONFIG_ENV_ARGS=/opt/freeware/bin/bash
export CC=cc
export CFLAGS="-qmaxmem=16384 -DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_ALL_SOURCE -DFUNCPROTO=15 -O -I/opt/freeware/include"export CXX=xlC
export CXXFLAGS=$CFLAGS
export F77=xlf
export FFLAGS="-qmaxmem=16384 -O -I/opt/freeware/include"
export LD=ld

export LDFLAGS="-L/opt/freeware/lib64 -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib:/opt/freeware/lib/mysql/mysql -Wl,-bmaxdata:0x80000000"

export PATH=/usr/bin:/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/vac/bin:/usr/vacpp/bin:/usr/ccs/bin:/usr/dt/bin:/usr/opt/perl5/bin:/opt/freeware/bin:/opt/freeware/sbin:/usr/local/bin:/usr/lib/instl
make clean
./configure 
--with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql 
--without-getopt 
--enable-openssl 
--with-includes=/home/padubois/include3_mysql/zlib/:/home/padubois/include_mysql/mysql/ 
--with-libraries=/opt/freeware/lib/mysql/mysql:/opt/freeware/lib/mysql/mysql/libmysqlclient.a 
--prefix=/local/proftpd/
make

我誤LDFLAG用了這裡的重要部分:

-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib:/opt/freeware/lib/mysql/mysql

新年快樂

編輯 2我看到另一行很奇怪:

--with-includes=[...]/opt/freeware/lib/mysql/mysql 

不應該是這樣/opt/freeware/include/mysql/mysql嗎?

此外,您在編譯時還沒有添加/opt/freeware/lib/mysql/mysql到 LDFLAGS 中。

編輯我看到一件事可以解釋它:

/opt/freeware/lib/mysql/mysql//libmysqlclient.a(libmysqlclient.so.16)

注意那裡的額外/內容。我絕不是 xl 方面的專家,但如果您在兩個編譯器中編譯時使用相同的符號,它可能會對此感到困惑。

(原答案:根據我對AIX的模糊記憶,相信你是想添加環境變數的路徑LIBPATH。)

引用自:https://unix.stackexchange.com/questions/107525