2012-01-04 60 views
1

這裏是命令和錯誤。鏈接錯誤:在RHEL 6.0上使用gcc 4.5.2 - 我不明白

gcc --shared \ 
     -m64 \ 
     -shared-libgcc \ 
     -Wl,--whole-archive ./release64/*.a 
/usr/lib64/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init': 
(.text+0x1d): undefined reference to `__init_array_end' 
/usr/bin/ld: /usr/lib64/libc_nonshared.a(elf-init.oS): relocation R_X86_64_PC32 against undefined hidden symbol `__init_array_end' can not be used when making a shared object 
/usr/bin/ld: final link failed: Bad value 
collect2: ld returned 1 exit status 
make: *** [build] Error 1 

這是什麼意思?

+0

您是否嘗試關閉該鏈接器選項('-Wl, - no-whole-archive'後面的'.a'文件)? – Mat 2012-01-04 21:08:05

回答

5

通過留下一個「懸掛」--whole-archive選項,可以欺騙GCC嘗試將編譯時沒有-fPIC(從libc_nonshared.a)編碼的代碼鏈接到共享庫中。不要做。改爲:

gcc -shared ... -Wl,--whole-archive release64/*.a -Wl,--no-whole-archive