+z +Z compiler flag for HP
1.??????今天遇到一問題,在sles11/vxworks下編譯通過,但是在hpux下失敗
2.??????編譯錯(cuò)誤:
/usr/ccs/bin/ld:DP relative code in file /projects/xxx/DERIVED/tfa_pa32-hpux.a(tfa02_pa32-hpux.o) -shared library must be position
??? independent.? Use +z or +Z to recompile.
3.????修改makefile,添加+z選項(xiàng)
ifeq($(BLD_TARGET_ARCH),pa32-hpux)
TS_LOGLIB_OPTS.o+= +z
endif
4.????重新編譯
5.????報(bào)新的錯(cuò)誤如下:
/usr/ccs/bin/ld:Data Linkage Table (+z) overflow in file /projects/xxx/loglib_pa32-hpux-mt.a(a7ts_log_pa32-hpux-mt.o)- use +Z option to recompile
?? Reference from:? /projects/xxx/loglib_pa32-hpux-mt.a(a7ts_log_pa32-hpux-mt.o)(0x604)
6.????查詢+z 和 +Z 的區(qū)別,如下:
+z,+Z Both ofthese options cause the compiler to generate?position independent code(PIC) for use in building?shared libraries. +Z is the default in 64-bitmode.?The -G and -p options are ignored if +z or +Z is used.?Normally,+z should be used to generate PIC; however,?when certain limits areexceeded, +Z is required to?generate PIC. The ld linker issues theerror?indicating when +Z is required. If both +z and +Z are?
specified, only the last one encountered applies. For?a more completediscussion regarding PIC and these?
options, see HP-UX Linker and Libraries Online User's?Guide and the manualProgramming on HP-UX.??
7.??????修改makefile,添加+Z選項(xiàng):
ifeq($(BLD_TARGET_ARCH),pa32-hpux)
TS_LOGLIB_OPTS.o+= +Z
endif
8.????編譯通過。
9.????結(jié)論:
9.1??+z/+Z 相當(dāng)于gcc 中的-fPIC;
(The '+Z' refers to *compiler* flag for HP cc/CC, which isequivalent to '-fPIC' for gcc.)
9.2??+z +Z有區(qū)別;
9.3??這個(gè)選項(xiàng)是編譯(compile)選項(xiàng),而不是鏈接(ld)選項(xiàng);
總結(jié)
以上是生活随笔為你收集整理的+z +Z compiler flag for HP的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求证!究竟是谁的审美观出了问题!?[已扎
- 下一篇: ldconfig及 LD_LIBRARY