2012-07-05 220 views
1

我是Ubuntu的新手,並且正在Amazon EC2雲中運行Ubuntu。在Ubuntu EC2實例上找不到libdl.so

我試圖編譯在Ubuntu上盒(i386amd64cppunit,它不會鏈接到libdl

g++ -g -O2 -o .libs/DllPlugInTester DllPlugInTester.o CommandLineParser.o -ldl ../../src/cppunit/.libs/libcppunit.so -lm -Wl,--rpath -Wl,/home/ubuntu/cppunit/lib 
../../src/cppunit/.libs/libcppunit.so: undefined reference to `dlsym' 
../../src/cppunit/.libs/libcppunit.so: undefined reference to `dlopen' 
../../src/cppunit/.libs/libcppunit.so: undefined reference to `dlclose' 

現在我不明白的是libdl.so存在無誤:

[email protected]:~/cppunit$ ls /lib/i386-linux-gnu/libdl* 
/lib/i386-linux-gnu/libdl-2.15.so /lib/i386-linux-gnu/libdl.so.2 

whereis什麼也沒有:

[email protected]:~/cppunit$ whereis libdl 
libdl: 

libc6安裝:

[email protected]:~/cppunit$ sudo apt-get install libc6 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
libc6 is already the newest version. 
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 

那麼,爲什麼我的構建找不到呢?

uname -r3.2.0-25-virtual

「正常」whereis在Fedora上看起來是這樣的:

[matt cppunit] whereis libdl 
libdl: /lib/libdl.so /usr/lib/libdl.so /lib64/libdl.so /usr/lib64/libdl.so 

任何想法?

編輯:我/etc/ld.so.conf.d/*.conf似乎是合理的:

[email protected]:~$ cat /etc/ld.so.conf.d/*.conf 
/usr/lib/i386-linux-gnu/mesa 
# Multiarch support 
/lib/i386-linux-gnu 
/usr/lib/i386-linux-gnu 
/lib/i686-linux-gnu 
/usr/lib/i686-linux-gnu 
# libc default configuration 
/usr/local/lib 
# This directive teaches ldconfig to search in nosegneg subdirectories 
# and cache the DSOs there with extra bit 1 set in their hwcap match 
# fields. In Xen guest kernels, the vDSO tells the dynamic linker to 
# search in nosegneg subdirectories and to match this extra hwcap bit 
# in the ld.so.cache file. 
hwcap 1 nosegneg 

回答

3

我也遇到了這個在64位的Ubuntu,GCC 4.6.3,我的預感是鏈接lib中的排序。然而,同樣的事情建立在32位上。 我在鏈接命令的末尾添加了-ldl並將其鏈接,因此看起來像某種鏈接器問題。 你也可以在shell中設置env var:LIBS = -ldl,它會生成。

+0

這是_exactly_我​​們也找到了。奇怪的是,它在32位,但不是64位。 – 2012-07-27 08:33:52

1

由於ld.so.conf用於動態鏈接程序,而不是組裝後鏈接程序ld(1)。有人創建了這條新路徑,但沒有更新鏈接器搜索的目錄。 libdl的/ lib64或/ usr/lib64中應該有一個鏈接,或者鏈接器搜索鏈接64位對象的路徑之一。

這個(新的路徑)是我的PoV的另一個例子,它是各種Linux發行版在不完全理解後果或歷史的情況下做出的隨機變化。