2013-06-11 31 views
0

我正在使用記錄庫,另一個名爲庫中liblogger,(我已經實現),libmsg。對於他們兩個,我使用自動工具。我成功地將liblogger庫安裝在我的系統中的/ usr/local/lib目錄下。配置發現庫,但LDD不

中的其他libmsg的configure.ac腳本,我確認liblogger被安裝在系統中,如下:

AC_CHECK_LIB([logger], 
      [log_init], 
      [], 
      [ 
       echo "Error: Could not find liblogger." 
       exit 1 
      ]) 

並添加 「-L在/ usr/local/lib目錄」 LDFLAGS變量的路徑。

AC_CHECK_LIB測試發現該庫,並且libmsg庫及其使用的check_PROGRAMS都已成功編譯。

然而,當我嘗試執行測試程序,我得到的錯誤:

error while loading shared libraries: liblogger.so.0: cannot open shared object file: No such file or directory

事實上,LDD沒有找到庫之一:

$ ldd msgs 
    linux-vdso.so.1 => (0x00007fff543ff000) 
    liblogger.so.0 => not found 
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fdf329ad000) 

但庫實際上,在/usr/local/lib

爲了連接測試程序,libtool的是被稱爲與指令:

$ /bin/bash ../libtool --tag=CC --mode=link gcc -I../include -I../msg -L/usr/local/lib -O2 -Wall -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -I/usr/local/lib -L/usr/local/lib -o msgs msgs.o message.o base64.o misc.o -llogger -lglib-2.0 

哪個實際回波以下:

libtool: link: gcc -I../include -I../msg -O2 -Wall -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -I/usr/local/lib -o msgs msgs.o message.o base64.o misc.o -L/usr/local/lib /usr/local/lib/liblogger.so -lglib-2.0 

所以,-llogger標誌被取代的-L [..] /usr/local/liblogger.so(我想這是一個正確的行爲?我還沒有能夠確定它......)

其實,如果我所說的測試程序和:

LDPRELOAD=/usr/local/lib/liblogger.so msgs

它的實際工作。

誰能告訴我什麼是我失蹤?

回答

2

您需要檢查:

  • /usr/local/lib/etc/ld.so.conf(通常是這些天)。
  • ldconfig在安裝liblogger時運行。如果沒有,運行它。
  • liblogger.so.0實際上是/usr/local/lib
+0

'ldconfig'實際上並沒有運行。它確實解決了這個問題,謝謝。有什麼辦法讓libtool自動執行它? – Ginswich

+1

'libtool'不應該執行'ldconfig'。即使'make install'說後運行'ldconfig',而不是自己運行它。通常包管理器(RPM,apt等))運行它,因爲它實際上只需要在第一次安裝lib(並在卸載之後)時運行。運行'ldconfig'它通常也需要root權限。 – ldav1s