File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes Creating the shared library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Creating the shared library" Watch "Creating the shared library" New topic

Creating the shared library

sridevi kumar
Ranch Hand

Joined: Oct 17, 2001
Posts: 31
I am trying to create a shared library in HP Unix 10.20.
I gave the command like this:
g++ -o -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

Joined: Jun 25, 2001
Posts: 17417

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.

An IDE is no substitute for an Intelligent Developer.
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
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 ]
I agree. Here's the link:
subject: Creating the shared library
jQuery in Action, 3rd edition