Compiling jni with .a library in linux

M

Mark Chavira

I am trying to create a java interface to a bunch of .a libraries. I am
using linux. I have put the "native" methods in the java code and
implemented them in mark_cudd_Native.c. The .a files are called cudd.a,
mtr.a, obj.a, st.a, util.a, and epd.a. I am trying then to compile
mark_cudd_Native.c and link mark_cudd_Native.o and all of the .a files
like this:

gcc -o libcudd.so -shared -Wl,-soname,libnative.so \
-static -lc \
-lobj -lcudd -lmtr -lst -lutil -lepd \
-I/export/home/jdk1.2/include \
-I/export/home/jdk1.2/include/linux \
-I $MYCUDD/cudd \
-I $MYCUDD/mtr \
-I $MYCUDD/st \
-I $MYCUDD/util \
-I $MYCUDD/epd \
-I $MYCUDD/obj \
-L$MYCUDD/cudd \
-L$MYCUDD/mtr \
-L$MYCUDD/st \
-L$MYCUDD/util \
-L$MYCUDD/epd \
-L$MYCUDD/obj \
mark_cudd_Native.c

But the .a files don't get linked in. Can somebody suggest a change to
my compile command? Thanks!

Mark
 
G

Gordon Beaton

I am trying then to compile mark_cudd_Native.c and link
mark_cudd_Native.o and all of the .a files like this:
[...]

But the .a files don't get linked in. Can somebody suggest a change
to my compile command? Thanks!

Order is important: specify the -l options at the *end* of the command
line. In particular, each file or library must precede any other files
or libraries it depends on, or the linker won't look for missing
symbols there.

See:
http://gcc.gnu.org/onlinedocs/gcc-3.3.2/gcc/Link-Options.html

/gordon
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top