[英]Adding -fPIC option in Imake file
我正在使用 Imakefile 制作 Makefile。 我收到編譯錯誤。
rm -f /vobs/eagle/build/linux/debug/lib/libTestRtip.so
/usr/bin/g++ -Wl,-soname,libTestRtip.so /vobs/eagle/build/linux/debug/obj/TestRtip.oo - L/vobs/eagle/build/linux/debug/lib -L/vobs- ads/outsource/ace610_linux_64bit/ACE_wrappers/lib/linux -L/vobs- ads/outsource/log4cxx/linux/lib64 -shared -o /vobs/eagle/build/linux/debug/lib/libTestRtip.so
/usr/bin/ld: /vobs/eagle/build/linux/debug/obj/TestRtip.oo: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/vobs/eagle/build/linux/debug/obj/TestRtip.oo: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [/vobs/eagle/build/linux/debug/lib/libTestRtip.so] Error 1
我不知道在 Imakefile 中在哪里添加 -fPIC。
PIC - 位置無關代碼。 這是一個標志 ( -f
),用於編譯器輸出目標文件,其代碼與它在內存中的位置無關。 這通常是庫 ( .so
) 的必備條件。
所以,正如我所說,它是一個編譯器標志,所以你應該查看你的Makefile中的CFLAGS
變量並將其添加到那里。
您的 CFLAGS 可能如下所示:
CFLAGS = -g -O0 -I/usr/local/include
你的工作是:
CFLAGS = -g -O0 -I/usr/local/include -fPIC
或者,您可以這樣制作:
$ make CFLAGS="-fPIC" all
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.