8

I'm trying to get OpenCV set up in IntelliJ, however I'm stuck on figuring out how tell IntelliJ where to find the native library location.

In Eclipse, after adding a jar, you can set the location of the Native library in the Build Config screen.

e.g.

enter image description here

Does anyone know how to do this in IntelliJ IDE?

Sarkis
  • 303
  • 2
  • 12
user3308774
  • 1,354
  • 4
  • 16
  • 20

4 Answers4

6

I'm not sure you need it as a dependency, you just need to add the option to the VM invocation so the library is found at run-time.

At least in the first sample I have looked at (samples/java/ant/SimpleSample) the native library is loaded at runtime with these lines:

SimpleSample code screencapture

So, the library is not a compiM to find the native library at run-time, specify the java.library.path to point to the directory where the library can be found, using the -D VM option - in your IntelliJ run configuration.

Run Configuration for JAR Application specifying where to find native library

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

Andrew Mackenzie
  • 5,477
  • 5
  • 48
  • 70
6

Once the library is added, you can set the Native Library Location as follows:

  1. Make sure the library is selected (highlighted). In my case, there only is one Library called lwjgl.
  2. On the right panel, select the little + Symbol (below "Name" and above "Classes")
  3. Select the directory you want to specify as Native Library Location and confirm
  4. Select Native Library Location in the next dialog.

Screenshot of Category Selection Dialog

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
WhiteStripes
  • 165
  • 1
  • 6
0

File-->Project Structure-->Modules-->Select Dependencies Tab-->Select Module Source-->at the right corner green '+' button-->Library-->new Library-->java-->select External jar file-->OK-->add Selected

or

Without selecting library from + button directly select jar dependencies

here are some screenshots

enter image description here

enter image description here

prasadmadanayake
  • 1,415
  • 15
  • 23
  • So you're explaining how to add external jars...he's wanting to know how to associate .dll files or .so files. – Uncle Iroh Nov 24 '14 at 20:10
  • However, it helped me, thanks a lot. Still not upvoting, as it might be wrong answer to the question, which i did not read lol – Christoph Jun 30 '17 at 15:29
0

https://stackoverflow.com/a/7148086/222867

Windows uses the PATH variable instead of LD_LIBRARY_PATH to load DLL's. I set the PATH environment variable appropriately and then restart Idea. This however, may not be the most convenient option

Community
  • 1
  • 1
qwerty
  • 3,801
  • 2
  • 28
  • 43