vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I want to build a shared library(libocl.sl) which uses roguewave tools.h++. I don't want to link to the librwtool.sl since I don't like my target having unnecessary runtime dependancy. So I tried to link to the static archive /usr/lib/librwtool.a instead, but got the following linking error: >/opt/aCC/bin/aCC +O2 +inst_v +eh "-Dstd=" +DA2.0 +W740,600,908,684,5004,829,741,749,823,495,438,863 ,336,612,552 -z -ext -w -Wl,-N +Z -Wl,+s +Oprocelim -Wl,+nommap -b -o libocl.sl -Wl,-Fl libmyosl.a -lstream -lstd -l:librwtool.a -L/opt/jdk1.4.1_02/jre/lib/PA_RISC/server -ljvm -lrt /usr/ccs/bin/ld: DP relative code in file /usr/lib/librwtool.a(cstring.o) - shared library must be position independent. Use +z or +Z to recompile. My understanding on this error is that librwtool.a has non-relocatable stuff in it, and it needs to be rebuilt with +z or +Z flag. (Am I right ?) However, I found that /usr/lib/librwtool.a is identified as "relocatable" library: >file /usr/lib/librwtool.a /usr/lib/librwtool.a: archive file -PA-RISC1.1 relocatable library I am totally lost here. I wonder how I can know whether an archieve is position independant or not ? Is it ever possible to build a shared library from an archieve librwtool.a. If it is not position independant, where can I find one ? Is there anything wrong with my compilation ? Thanks, C.J. |
| |||
| Answer From Dennis Handly: >I want to build a shared library(libocl.sl) which uses roguewave >tools.h++. I don't want to link to the librwtool.sl since I don't like >my target having unnecessary runtime dependency. Archive libs are evil, you should never use them except as containers for objects of your sources. Always use shared libs if possible. >ld: DP relative code in file librwtool.a(cstring.o) - shared library must >be position independent. Use +z or +Z to recompile. >My understanding on this error is that librwtool.a has non-relocatable >stuff in it, and it needs to be rebuilt with +z or +Z flag. Correct. You must purchase SourcePro from Rogue Wave and compile your own. >I found that /usr/lib/librwtool.a is identified as "relocatable" library: Relocatable Library (RL) is the MPE/iX buzzword for archive lib. >I wonder how I can know whether an archive is position independent or not? By using the linker and getting errors or odump -fix to look at the fixups? Or using odump -comp (or elfdump -dc) to look at the compunit compile options. >If it is not position independent, where can I find one? You'll have to buy and make one yourself. Or use templates and functions from the C++ Standard Library and use the shared version of that. |
| ||||
| Answer from Carl Burch: And in this case it's both possible and easy - a "necessary" runtime dependency. Just link your shared library against the librwtool.sl and document the dependency for your customers. See the "Linker and Libraries Users Guide" at http://docs.hp.com/hpux/onlinedocs/d...355-90730.html for more details about dependent libraries. >I found that /usr/lib/librwtool.a is identified as "relocatable" library: What Dennis meant to say was that "relocatable" is not synonymous with "position-independent", which is the kind of code necessary to be linked into a shared library. Any relocatable code can be linked into an executable, but not into a shared library. Very few "relocatable" files are position-independent on systems like PA32 where that's not the default. HP-UX compilers for PA64 and Itanium produce position-independent code by default, so most relocatable files you'll find there will also be position-independent. - Carl Burch |