java - Including native c++ .so library in IntelliJ using JNI under Ubuntu -


i'm building shared library called java intellij using jni under ubuntu 14.04 x64. when calling .so file using system.loadlibrary("libtestjnilib") in intellij got following error:

exception in thread "main" java.lang.unsatisfiedlinkerror: no libtestjnilib in java.library.path 

the intellij configurations determine path library:

1) run->edit configurations->vm options: -djava.library.path=/home/username/libs 2) in "project structure -> libraries ->native library locations" 

i added same path: /home/username/libs

when testing using method mentioned below have correct path.

string javalibpath = system.getproperty("java.library.path"); 

intellij's started under root.

when you're loading shared library using system.loadlibrary(), following applies:

loads system library specified libname argument. the manner in library name mapped actual system library system dependent.

the best description can find mapping here:

each java runtime environment provides platform-dependent mechanism mapping between actual file name of shared library , name string pass argument system.loadlibrary method.

solaris:

the shared library file name requires "lib" prefix , ".so" extension. not include "lib" prefix or ".so" extension argument pass system.loadlibrary method.

microsoft windows:

the shared library file name requires ".dll" extension.
not include ".dll" extension system.loadlibrary method argument.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -