This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating the shared library

 
sridevi kumar
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic