By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,581 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,581 IT Pros & Developers. It's quick & easy.

JNI:"undefined symbol" in "shared-library"

P: n/a
Hello,

I would like to call a C++ programm out of Java with help of JNI. By the
followed command I created a "shared library":
g++ -shared -o libcalculate.so rechner.cpp

When I create an object from the existing program inside a method of my
class rechner.cpp, and then call the method out of java, a following
error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/home/home12/kahl/six-cvs/six-0.5.2/six/javainterface/libcalculate.so:
/home/home12/kahl/six-cvs/six-0.5.2/six/javainterface/libcalculate.so:
undefined symbol: _ZN9DualBatch13setConnLimitsEjj
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1676)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at Calculate.<clinit>(Calculate.java:16)
at DerJavaRechner.main(DerJavaRechner.java:10)

If I do not create such an object, everything is fine.

I already posted my problem in a german group, but did not get an answer
until now.

Thanks for your help.
Ken
Feb 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
TB
Kenneth Kahl skrev:
Hello,

I would like to call a C++ programm out of Java with help of JNI. By the
followed command I created a "shared library":
g++ -shared -o libcalculate.so rechner.cpp

When I create an object from the existing program inside a method of my
class rechner.cpp, and then call the method out of java, a following
error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/home/home12/kahl/six-cvs/six-0.5.2/six/javainterface/libcalculate.so:
/home/home12/kahl/six-cvs/six-0.5.2/six/javainterface/libcalculate.so:
undefined symbol: _ZN9DualBatch13setConnLimitsEjj
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1676)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at Calculate.<clinit>(Calculate.java:16)
at DerJavaRechner.main(DerJavaRechner.java:10)


Java exceptions. That would be a hint. The Java loader/linker apparently
can't interface correctly with libcalculate.so, but for a more
detailed, and possibly more correct answer, try posting to a Java
group instead.

--
TB @ SWEDEN
Feb 21 '06 #2

P: n/a
Put your natice C++- code between
extern "C" {
your code
}

"Kenneth Kahl" <ke**********@udo.edu> schrieb im Newsbeitrag
news:dt**********@nx6.HRZ.Uni-Dortmund.DE...
Hello,

I would like to call a C++ programm out of Java with help of JNI. By the
followed command I created a "shared library":
g++ -shared -o libcalculate.so rechner.cpp

When I create an object from the existing program inside a method of my
class rechner.cpp, and then call the method out of java, a following
error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/home/home12/kahl/six-cvs/six-0.5.2/six/javainterface/libcalculate.so:
/home/home12/kahl/six-cvs/six-0.5.2/six/javainterface/libcalculate.so:
undefined symbol: _ZN9DualBatch13setConnLimitsEjj
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1676)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at Calculate.<clinit>(Calculate.java:16)
at DerJavaRechner.main(DerJavaRechner.java:10)

If I do not create such an object, everything is fine.

I already posted my problem in a german group, but did not get an answer
until now.

Thanks for your help.
Ken

Feb 22 '06 #3

P: n/a
Thanks for your idea. I tried it that way, but it did not work.
Nevertheless I could solve the problem.
The command "ldd -d libcalculate.so" on my library gave me the output:

libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0xb7f2d000)
libm.so.6 => /lib/tls/libm.so.6 (0xb7f0a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7f01000)
libc.so.6 => /lib/tls/libc.so.6 (0xb7dcc000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
undefined symbol: _ZN9DualBatch13setConnLimitsEjj (./libcalculate.so)
undefined symbol: _ZN9DualBatch13setSemiLimitsEjj (./libcalculate.so)
undefined symbol: _ZN7Carrier8bitsIn16E (./libcalculate.so)

There are three undefined symbols in the library. The first and the
second of them contain the string "Batch" and the third contains the
string "carrier". In the c++ program that I want to use are the classes
batch.cpp and carrier.cpp. So I created the library in that way:

g++ -shared -o libcalculate.so rechner.cpp batch.cpp carrier.cpp

And now everything works fine.

Ken
Sven Fülster wrote:
Put your natice C++- code between
extern "C" {
your code
}

Feb 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.