2012-04-12 12 views
1

私はx86_64マシン上RHEL 5.8の午前:i386互換性があるようにソースをコンパイルクロスへRHELリンカエラー

$ uname -r 
2.6.18-308.1.1.el5 
$ uname -m 
x86_64 
$ 

試してみてください。

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または他の選択肢はありますか?

+1

あなたはまた 'libuuid.so持っていますか - に/ libに> libuuid.so.1.2'シンボリックリンク? – rwos

+0

私はリンクを作成し、バイナリをコンパイルしました。答えを投稿してください。私はそれを受け入れる。 –

答えて

2

リンカーはバージョン番号( "libuuid.so")なしでライブラリ名のみを検索します。このコンベンションでは、soname(この場合は "libuuid.so.1"となります)へのシンボリックリンクがあります。実際の共有ライブラリ(この場合は "libuuid.so.1.2")へのシンボリックリンクです。

したがって、リンカーがライブラリを検索するには、/libにこれらのシンボリックリンクが必要です。

(このトピックの詳細:http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

1

特定の共有オブジェクトとリンクする場合は、コンパイラまたはリンカーに直接渡す必要があります。