Using maven to create / deploy / use projects with JNI

I am trying to use maven to create a project that depends on the JNI wrapper around the OpenCV computer view library. I was able to "maven-ize" the OpenCV wrappers here: http://ubaa.net/shared/processing/opencv/ using the FreeHEP NAR maven plugin, but the documentation for that plugin is somewhat lacking.

I managed to create a project (imagedetect) which depends on the OpenCV java project (I call it OpenCVJava). imagedetect will compile, however, any test, integration-test, or package target is not in error with libraries missing from java.library.path.

!!! required library not found : no OpenCV in java.library.path Verify that the java.library.path property is correctly set and 'libcxcore.so', 'libcv.so', 'libcvaux.so', 'libml.so', and 'libhighgui.so' are placed (or linked) in one of your system shared libraries folder 

This is especially unpleasant - the only way to solve this problem is to somehow track the .nar file for opencv libraries, manually extract them, install java.library.path, and then call the gnaraly java command to actually run the tests / applications using the appropriate pathpath / library. This will not work - especially if this problem persists in transitive dependencies.

How can I clean the build / test / run system? I'm not configured for FreeHEP, but I would like to stick with maven as it makes our most common use cases a lot easier.

FreeHEP Nar plugin: http://java.freehep.org/freehep-nar-plugin/intro.html

+4
source share
1 answer

I am not familiar with FreeHEP, but if you had problems setting java.library.path on surefire to run your tests, I found an example: http://buildanddeploy.com/node/14 This is a bit related to the publication, but shows how to make maven copy its own libraries to a directory, which is then listed on your java.library.path. I have used a similar approach in the past.

Also, looking at the error, did you need to set LD_ LIBRARY_ PATH to fix it? If so, you should get this set within maven.

Here is an example of how to set this for surefire (from http://docs.codehaus.org/display/MAVENUSER/Projects+With+JNI ): Maven-error-free-plugin once target / tmplib java.library.tmpdir target / tmplib

+4
source

All Articles