[英]RHEL linker error
我在x86_64
機器上的RHEL 5.8
:
$ uname -r
2.6.18-308.1.1.el5
$ uname -m
x86_64
$
嘗試交叉編譯源代碼以兼容i386
:
CFLAGS += -m32
LDFLAGS += -L/lib -lpthread -luuid
但鏈接階段失敗並出現錯誤:
/usr/bin/ld: skipping incompatible /usr/lib64/libuuid.so when searching for -luuid
/usr/bin/ld: skipping incompatible /usr/lib64/libuuid.a when searching for -luuid
/usr/bin/ld: cannot find -luuid
collect2: ld returned 1 exit status
實際上,主機有/lib/libuuid.so.1.2
:
$ readelf -h /lib/libuuid.so.1.2
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0xf90
Start of program headers: 52 (bytes into file)
Start of section headers: 13352 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 28
Section header string table index: 27
$
是否有任何ld
或其他選項來解決此鏈接問題?
鏈接器僅搜索庫名稱,而不搜索版本號(“libuuid.so”)。 慣例是將其符號鏈接到soname
(在本例中為“libuuid.so.1”),而后者又是真實共享庫的符號鏈接(在本例中為“libuuid.so.1.2”)。
因此,您需要/lib
中的這些符號鏈接以便鏈接器找到庫。
(更多關於這個主題: http : //tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html )
如果要鏈接特定的共享對象,則必須將其直接傳遞給編譯器或鏈接器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.