Hi: I am trying to create a shared library in HP Unix 10.20. I gave the command like this: g++ -o test.so -shared -I/opt/java/include -I/opt/java/include/hp-ux test.cpp -static -lc I had included /opt/java/include bcoz it has jni.h and i had included /opt/java/include/hp-ux bcoz it has jni_md.h When i tried to create a shared lib (by issuing the above command), it throws the error message as follows: /usr/ccs/bin/ld: DP relative code in file /var/tmp/ccaGpcIE.o - shared library m ust be position independent. Use +z or +Z to recompile. collect2: ld returned 1 exit status Could anyone please help me to solve this? Thanks a lot.
I don't know the solution, but I know the problem. You're telling it to create a module where addresses are absolute - the module isn't relocatable within the memory space.
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
posted
0
Hi - Unfortunately, I do not have a solution. I really know nothing about the HP compiler/linker. Every 'unix' system I've worked on is different when it comes to shared libraries. Looking at your command line, I am suspicious about the "-static" option. What does it do? I guess I would try running the compile and link separately: g++ -c xxxx.cpp -I...... g++ -o .....xxxx.o .... And also read your local man pages regarding shared libraries. At least figure out what the z/Z option does. Regards, Guy [ February 06, 2002: Message edited by: Guy Allard ]