JNI: shared library has undefined symbol

  • Thread starter dimitrios.kapanikis
  • Start date
D

dimitrios.kapanikis

Hello,

I am trying to call a C++ function through JNI, but when I execute my
Java programm I get this exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
/dualy/home/kapanikis/set_on_top.so:
/dualy/home/kapanikis/set_on_top.so: undefined symbol:
_ZN4KWin15setActiveWindowEm
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
at java.lang.Runtime.load0(Runtime.java:769)
at java.lang.System.load(System.java:967)
at SetOnTop.<clinit>(SetOnTop.java:18)

after using nm set_on_top.so it actually told me that setActiveWindow
is not defined. This is my compile command:

g++ -fPIC -shared -lstdc++ -Wl,-soname=kwin.so -I
/linuxtools/apps/j2sdk1.4.2_06/include -I /usr/include/kde -I
/usr/include/qt3 -I /usr/lib/kde3 -L/usr/lib/kde3 -lqt-mt -lqtmcop -I
/linuxtools/apps/j2sdk1.4.2_06/include/linux set_on_top.cpp -o
set_on_top.so

The part -Wl,-soname=kwin.so doesnt change anything if it appears in
the compile command or not.

Can anybody give me help me or give me a hint?

Thank you,
Dimitrios Kapanikis
 
N

Nigel Wade

Hello,

I am trying to call a C++ function through JNI, but when I execute my
Java programm I get this exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
/dualy/home/kapanikis/set_on_top.so:
/dualy/home/kapanikis/set_on_top.so: undefined symbol:
_ZN4KWin15setActiveWindowEm
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
at java.lang.Runtime.load0(Runtime.java:769)
at java.lang.System.load(System.java:967)
at SetOnTop.<clinit>(SetOnTop.java:18)

after using nm set_on_top.so it actually told me that setActiveWindow
is not defined. This is my compile command:

g++ -fPIC -shared -lstdc++ -Wl,-soname=kwin.so -I
/linuxtools/apps/j2sdk1.4.2_06/include -I /usr/include/kde -I
/usr/include/qt3 -I /usr/lib/kde3 -L/usr/lib/kde3 -lqt-mt -lqtmcop -I
/linuxtools/apps/j2sdk1.4.2_06/include/linux set_on_top.cpp -o
set_on_top.so

The part -Wl,-soname=kwin.so doesnt change anything if it appears in
the compile command or not.

Can anybody give me help me or give me a hint?

Find where setActiveWindow is defined, and make sure your DSO is linked against
it to resolve the unsatisfied external. You might want to note that the actual
unresolved external is _ZN4KWin15setActiveWindowEm, which probably indicates
some C++ name mangling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top