Operating System - HP-UX
1833588 Members
4267 Online
110061 Solutions
New Discussion

Creating shared library for JNI

 
SOLVED
Go to solution
Manoj_19
New Member

Creating shared library for JNI

Hi,
I have a similar problem as the one mentioned below 'JNI calling C program'

I am trying to make a shared library using aCC. I intend to call this library from a Java program using JNI.
The C program calls some other libraries for Arbor (a billing product used in telecom applications). The program basically calls APIs defined in these Arbor libraries. I am compiling in the foll. format

aCC -b +z -I/opt/java/include -I/opt/java/include/hp-ux $(LDFLAGS) $(LDLIBS) arborJniImpl.c -o libjniRef.sl
where LDFLAGS and LDLIBS point to all the include files and libraries for Arbor. arborJniImpl.c is my source file and libjniRef.sl is the shared library file that is to be generated.

The library file does get generated. But when my JNI program calls it, it prints a list of all the APIs during runtime that I have called for arbor saying "unresolved symbol"
e.g. /usr/lib/dld.sl: Unresolved symbol: insert_abp_serv_inst (code) from {shared library path and name}
The very first line of the error text has the following
aCC runtime: Error 215 from shl_findsym({shared library path and name})
Can anyone please point out where I am going wrong ?
Life is a beauty
1 REPLY 1
Mike Stroyan
Honored Contributor
Solution

Re: Creating shared library for JNI

You have LDLIBS before your source file in the link sequence. If any of those LDLIBS are archive libraries, then that could prevent the linker from pulling in .o files from the libraries which would satisfy the missing symbols. You could reorder the libraries or use the -Wl,+n option to tell the linker to repeatedly search archive libraries until there is no more progress on resolving symbols.