1

I am new to JNI.

I want to link a static library (say libFoo.a) into the dynamic library which I am creating. This dynamic library is being called from my Java class.

Is this possible? If so how?

gcc -I$JAVA_DIR/include -I$JAVA_DIR/include/linux  -o libXY.so -shared jni/xy.c libFoo.a
John Qualis
  • 1,663
  • 4
  • 33
  • 52

1 Answers1

1

Q: I want to link a static library (say libFoo.a) into the dynamic library which I am creating. Is this possible?

A: Sure. Just include your .a static library in the link command where you build your shared .so.

This has nothing to do with JNI per se - any shared binary (*nix .so or Windows .dll) can be linked into a shared library in this fashion.

These links should help:

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • What about a libtool based .la shared library like libX.la. Can I include that as well using the same method? I tried but get some errors. – John Qualis Apr 21 '13 at 10:35
  • What does mean "Just include your .a static library in the link command where you build your shared .so." ? Thanks. – toto_tata Jun 29 '21 at 14:57