How do you link your native library to a jar in IntelliJ?

I am trying to configure OpenCV in IntelliJ. However, I was fixated on telling IntelliJ where to find the location of my native library.

In Eclipse, by adding a jar, you can set the location of the main library directly on the Build Config screen.

eg.

enter image description here

Does anyone know how to do this in IntelliJ IDE?

+5
source share
3 answers

I'm not sure that you need this as a dependency, you just need to add an option to the VM call so that the library is at runtime.

At least in the first example I examined (samples / java / ant / SimpleSample), the built-in library is loaded at runtime with these lines:

SimpleSample Code Capture Screenshot

So, the library is not a compiler, to find its own library at runtime, specify java.library.path to point to the directory in which the library can be found using the -D VM option in your IntelliJ.

Run the configuration for the JAR application, which determines where to find the native library

NOTE. If on Mac OS X you need to create a copy / link of the .so shared library built on the same with the same name but the extension .dynlib

+5
source

fooobar.com/questions/207108 / ...

Windows uses the PATH variable instead of LD_LIBRARY_PATH to load the DLL. I set the PATH environment variable correctly and restarted Idea. This, however, may not be the most convenient option.

0
source

File → Project structure → Modules → Dependencies tab → Select module source → in the right corner of “+” → Library → New library → java → select External jar file → OK → Add selected

or

Without selecting library from + directly select jar dependencies

here are some screenshots

enter image description here

enter image description here

-1
source

Source: https://habr.com/ru/post/949674/


All Articles