A
Arne Styve
Hi,
I have a project where I use JNI to get access to a relatively simple C++
library provided as 3 DLLs. This library only requires the msv*.dll-files to
be present on the target machine to run.
I've created a class A with native methods, generated the corresponding C++
headerfile, and the guy coding the C++ library has implemented the
headerfile in a C++ file. Now his C++ library uses two other DLL's, in
adition to the msv*.dll's.
In Java, I load the DLL using
static { System.loadLibrary("testDll");}
When running my program, I have my application JAR placed in the same
directory as the 3 DLL's. I've also added the 3 msv*.dll-files to this
directory, including the Microsoft.VC80.CRT.manifest-file.
When running on my PC, it all works just fine, but when I move my JAR-file,
and all the DLL's and the manifest file to a different PC, I get the
following message:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Programfiler\OSC\test\testDll.dll:
An initiallisationroutine for a library with dynamic loading (DLL) failed
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at test.<clinit>(test.java:32)
at testModel.<init>(testModel.java:115)
at main(main.java:81)
at main.main(main.java:142)
NB! The text "An initiallisationroutine for a library for dynamic loading
(DLL) failed" is an attempted translation of the Norwegian:
"En initialiseringsrutine for et bibliotek for dynamiske koblinger (DLL)
mislyktes"
I've also tried installing the Microsoft Redistributable as described in
http://www.microsoft.com/downloads/...EE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
without success.
I've put my files on a memorystick, and tried running the application
directly from the stick on several PC's at our office, and on most of the
PC's the application runs fine, but on some of them I get the errormessage
above.
I've figured out that the Java-code does find the testDll.dll-file,
otherwise the errormessage would state:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no testDll in
java.library.path
...so I recon the error is within the test.dll-file, i.e. it is not able to
find the other dll's it is dependent on. I've tried DependencyWalker too,
but cannot find any differences between the PC's where it works, and the
PC's where it does not work.
The test.dll has it's manifest embedded by the way.
Anyone experienced a similar problem ?
What is the best practice when using JNI to access code developed with
MSVisual Studio ?
Regards
Arne
I have a project where I use JNI to get access to a relatively simple C++
library provided as 3 DLLs. This library only requires the msv*.dll-files to
be present on the target machine to run.
I've created a class A with native methods, generated the corresponding C++
headerfile, and the guy coding the C++ library has implemented the
headerfile in a C++ file. Now his C++ library uses two other DLL's, in
adition to the msv*.dll's.
In Java, I load the DLL using
static { System.loadLibrary("testDll");}
When running my program, I have my application JAR placed in the same
directory as the 3 DLL's. I've also added the 3 msv*.dll-files to this
directory, including the Microsoft.VC80.CRT.manifest-file.
When running on my PC, it all works just fine, but when I move my JAR-file,
and all the DLL's and the manifest file to a different PC, I get the
following message:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Programfiler\OSC\test\testDll.dll:
An initiallisationroutine for a library with dynamic loading (DLL) failed
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at test.<clinit>(test.java:32)
at testModel.<init>(testModel.java:115)
at main(main.java:81)
at main.main(main.java:142)
NB! The text "An initiallisationroutine for a library for dynamic loading
(DLL) failed" is an attempted translation of the Norwegian:
"En initialiseringsrutine for et bibliotek for dynamiske koblinger (DLL)
mislyktes"
I've also tried installing the Microsoft Redistributable as described in
http://www.microsoft.com/downloads/...EE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
without success.
I've put my files on a memorystick, and tried running the application
directly from the stick on several PC's at our office, and on most of the
PC's the application runs fine, but on some of them I get the errormessage
above.
I've figured out that the Java-code does find the testDll.dll-file,
otherwise the errormessage would state:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no testDll in
java.library.path
...so I recon the error is within the test.dll-file, i.e. it is not able to
find the other dll's it is dependent on. I've tried DependencyWalker too,
but cannot find any differences between the PC's where it works, and the
PC's where it does not work.
The test.dll has it's manifest embedded by the way.
Anyone experienced a similar problem ?
What is the best practice when using JNI to access code developed with
MSVisual Studio ?
Regards
Arne