Java - Can't find dependent libraries

10,219 views
Skip to first unread message

Solletjes Solletjes

unread,
Sep 19, 2014, 5:29:49 AM9/19/14
to or-tools...@googlegroups.com
Hello,

I'm trying to use or-tools from Java, but am not successful yet. I hope you can help me.

According https://code.google.com/p/or-tools/wiki/OrToolsWithJava, I downloaded and unzipped the Google.OrTools.java.VisualStudio2013-64b.3750.zip distribution.
To my knowledge, the important components needed to run samples are located in the lib folder, and these are
  • com.google.ortools.jar
  • jniortools.dll.

In eclipse, I created a Java project, added com.google.ortools.jar as referenced library, and copied jniortools.dll to C:\Windows (Also tried it in the eclipse project's root folder, that that was no difference).
Then I copied the NQueens.java sample to my project. The project compiles without errors, so com.google.ortools.jar seems to be referenced correctly.
However, when I run the NQueens.main() then I get an UnsatisfiedLinkError error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Windows\jniortools.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1872)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1087)
    at try_ortools.NQueens.<clinit>(NQueens.java:23)

   
Apparently, I'm missing some dll's that are used by jniortools.dll?
In another post, I saw a reference to msvcp100.dll and msvcr100.dll, but both are present in my C:\Windows folder.

Any suggestion about what I am missing?

Laurent Perron

unread,
Sep 19, 2014, 5:36:56 AM9/19/14
to or-tools...@googlegroups.com
I think visual studio 2013 requiers version 110 of the dlls.
Can you check this?

Did you add the -Djava.library.path=<path to the directory containing the jni dll> to the command line?

Thanks

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Solletjes Solletjes

unread,
Sep 19, 2014, 6:22:53 AM9/19/14
to or-tools...@googlegroups.com
Hi, thanks for the quick reply :-)

Both msvcp110.dll and msvcr110.dll are also present in my C:\Windows\System32 folder.
To my knowledge, the search path for dependent libraries automatically includes the working directory (i.e. the project's root folder for an eclipse project) and the Windows PATH. (according http://stackoverflow.com/questions/6092200/how-to-fix-an-unsatisfiedlinkerror-cant-find-dependent-libraries-in-a-jni-pro).

Although, I think redundant, I have tried running with
-Djava.library.path=C:\Windows\System32
and with
-Djava.library.path=C:\Data\Code\workspace\try_ortools
(the latter is my project's root where I have copied all of the msvcp*.dll and msvcr*.dll files I could find on my system).
No good result so far.

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Data\Code\workspace\try_ortools\jniortools.dll: Can't find dependent libraries

    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1872)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1087)
    at try_ortools.NQueens.<clinit>(NQueens.java:23)




Op vrijdag 19 september 2014 11:36:56 UTC+2 schreef Laurent Perron:

Laurent Perron

unread,
Sep 19, 2014, 8:17:00 AM9/19/14
to or-tools...@googlegroups.com
I believe there are tools like depends that tells you the dependencies of a dll.
Can you try that?

Thanks

Solletjes Solletjes

unread,
Sep 19, 2014, 11:43:42 AM9/19/14
to or-tools...@googlegroups.com
Ok, Dependency Walker did help me. Apparently I needed the 120 versions of those two dlls.

Solution for getting the Google.OrTools.java.VisualStudio2013-64b.3750.zip distribution working with eclipse (Kepler, Java 7) on Windows 7, 64 bit
  • downloaded the 64 bit version of msvcr120.dll from http://www.dll-files.com/dllindex/dll-files.shtml?msvcr120
  • downloaded the 64 bit version of msvcp120.dll from http://www.dll-files.com/dllindex/dll-files.shtml?msvcr120
  • copied both dll files to the root of my eclipse project. In this same folder I also copied jniortools.dll
  • On my eclipse java project, configured the Java Build Path through "Add External JARs..", so including com.google.ortools.jar
  • removed the earlier suggested -Djava.library.path=... from the Run Configuration in eclipse. Basically this put me back to a default Run Configuration

NQueens.main could now successfully run...I see output that ended with

Solutions: 92
Failures: 253
Branches: 688
Wall time: 26ms

Thanks for your help. Now the real fun should start :-)

Marc



Op vrijdag 19 september 2014 11:29:49 UTC+2 schreef Solletjes Solletjes:

Cemalettin Öztürk

unread,
May 23, 2015, 1:45:27 PM5/23/15
to or-tools...@googlegroups.com
Hi all, 

Thanks for your posts. This topic is the unique discussion on such a deep installation problem. 

I just want to fix the link of "msvcp120.dll" Solletjes povided :


Cemal
Reply all
Reply to author
Forward
0 new messages