Is it possible to link a static library to Java th

2019-02-13 09:36发布

Is it possible to build a HelloWorld.lib and load it to a Java application using JNI? Or it just works with shared libraries?

I couldn't find a clear answer on the JNI documentation, there's no reference to "static library".

4条回答
小情绪 Triste *
2楼-- · 2019-02-13 10:13

It needs to be a dynamic library. Fortunately, you can build a dynamic library from a static one.

查看更多
姐就是有狂的资本
3楼-- · 2019-02-13 10:20

Java 8 supports statically linked native libraries http://openjdk.java.net/jeps/178

查看更多
forever°为你锁心
4楼-- · 2019-02-13 10:25

You would have to link it to the JVM, and you don't have a way to do that. That's why JNI is defined with shared libraries, not static ones.

查看更多
Bombasti
5楼-- · 2019-02-13 10:30

To load a library at runtime it must be a dll (windows). If you have a static library (lib) and you have to use it via JNI you have to create a wrapper dll

查看更多
登录 后发表回答