On Thu, 5 Nov 1998, peter johnson wrote:
>
>
> Nicholas Matsakis wrote:
>
> > Briefly, I am trying to call a native method under Linux. I have a
> > decent understanding of the JNI, and have gotten my code to load under
> > windows, but am unable to load the shared library under Linux. Other
> > relevant details include my system profile: Slackware, libc.so.5, JDK 1.1.6v5
> >
> > As I understand it, the process is:
> >
> > 1) Write your java file, declaring native methods
> > 2) Run javah on the file to get your headers
> > 3) Implement the native methods in (my case in) C++
> > 4) Compile the C++ code to object files
> > 5) Link the object files into a shared library (are the following
> > compiler options sufficient?)
> >
> > gcc -lm -shared -Wl,-soname,libreceng.so -o libreceng.so lots_of_files.o
> >
> > I am currently not interested in putting version numbers on my shared
> > library, is that necessary?
> >
> > 6) Put the shared library in your shared library path. Where is this
> > path define, exactly? I'm using tcsh, and I presume that $LPATH is the
> > path I'm interested in.
> >
> > 7) Run your java.
> > --------------------------------------
> > At step 7 I get the following error:
> >
> > matsakis@natural-log>av index.html
> > File not found (libreceng.so)
> > Exception occurred during event dispatching:
> > java.lang.UnsatisfiedLinkError: no receng in shared library path
> > at java.lang.Runtime.loadLibrary(Runtime.java)
> > at java.lang.System.loadLibrary(System.java)
> > at NLI.RecEng.<init>(Demo.java:87)
> > at NLI.Demo.evaluate(Demo.java:70)
> > at NLI.Input_Panel.handleEvent(Input_Panel.java:38)
> > at java.awt.Component.postEvent(Component.java:1986)
> > at java.awt.Component.postEvent(Component.java:1996)
> > at java.awt.Component.postEvent(Component.java:1996)
> > at java.awt.Component.dispatchEventImpl(Component.java:1793)
> > at java.awt.Component.dispatchEvent(Component.java:1708)
> > at java.awt.EventDispatchThread.run(EventDispatchThread.java:81)
> >
> > Any suggestions?
> >
> > Nick Matsakis
>
> I'm not 100% sure, but I believe you have to use -PIC (position independent code)
> flag on the compile.
>
> Peter Johnson
> [EMAIL PROTECTED]
>
I am finding GNU's libtool very useful in this regards and reduces the
pain of creating the required shared libraries.
C.S.