+z +Z compiler flag for HP

1.      今天遇到一问题,在sles11/vxworks下编译通过,但是在hpux下失败

2.      编译错误:

/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选项

ifeq($(BLD_TARGET_ARCH),pa32-hpux)

TS_LOGLIB_OPTS.o+= +z

endif

4.    重新编译

5.    报新的错误如下:

/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 的区别,如下:

+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选项:

ifeq($(BLD_TARGET_ARCH),pa32-hpux)

TS_LOGLIB_OPTS.o+= +Z

endif

8.    编译通过。

9.    结论:

9.1  +z/+Z 相当于gcc 中的-fPIC;

(The '+Z' refers to *compiler* flag for HP cc/CC, which isequivalent to '-fPIC' for gcc.)

9.2  +z +Z有区别;

9.3  这个选项是编译(compile)选项,而不是链接(ld)选项;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值