Cannot get dependency to run in Intellij: UnsatisfiedLinkError - intellij-idea

I have a Play framework application in Intellij to which I am trying to add Gurobi (an ILP optimizer) and have been running into some problems. I have followed all of the instructions for installing Gurobi from their website.
In Intellij, I have added Gurobi to a /lib folder in the project, and it resolves all the symbols in the code OK, the code compiles, and I can run the application. I added Gurobi to the java library path by adding this to the JVM arguments to the run configuration:
-Djava.library.path=/opt/gurobi605/linux64/lib
I have also added 4 environment variables to the run configuration:
GUROBI_HOME="/opt/gurobi605/linux64"
PATH="${PATH}:${GUROBI_HOME}/bin"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
GUROBI_LICENCE="/home/mcmellawat/gurobi.lic"
I have also added these environment variables to the .bashrc file per Gurobi instructions, though I'm not sure it matters.
Despite all this, I am getting the following error when trying to instantiate the first Gurobi object (GRBEnv to be specific) in my code:
java.lang.UnsatisfiedLinkError: /opt/gurobi605/linux64/lib/libGurobiJni60.so: libgurobi60.so: cannot open shared object file: No such file or directory
I have verified that this file does indeed exist in /opt/gurobi605/linux64/lib (it is actually a link to another file). What could be causing it to not be found?

The Gurobi FAQ (41) contains instructions how to use the Java interface from a development environment (e.g. Eclipse):
http://www.gurobi.com/support/faqs
1) You need to include gurobi.jar in your project (e.g. in your Build Path)
2) Make sure that the environment variable PATH (Windows) or LD_LIBRARY_PATH (Linux) contains the correct library folder.
On Windows this is by default the bin folder of the Gurobi installation (e.g. gurobi60.dll and gurobi65.dll)
On Linux this is by default the lib folder of the Gurobi installation (e.g. libgurobi60.so and libGurobiJni60.so)

Related

Missing dll files error in Objective-C programs

I am a beginner in Objective-C language. I have downloaded and installed GNUstep msys and GNUstep core and installed them in order, as mentioned in the downloads page of GNUstep.
But, I think that the installation isn't correct, because whenever I try to compile an Objective-C source file, it shows fatal error Foundation/Foundation.h file not found. Means, due to some reasons, the path to the header files isn't valid.
Although I am now successfully able to compile the source file with the -I and -L options, I faced another problem. After compilation, when I run the compiled exe file, it shows an error that many dll files are missing, such as objc-4.dll, gnustep-base-1_24.dll to name a few of them. But, I found all of these files present under the /GNUstep/System/Tools folder. When I copied these dll files to my main working (home) directory, it runs successfully without any errors.
Why is this happening? All the tutorials I found on the internet shows very simply the compiling and running of Objective-C programs in Windows without changing so many things. Am I missing something? I have searched many times in StackOverflow and also on the internet, but none of those solved this problem. Please help me and thanks in advance.
P.S. - I have installed GNUstep in the default C:/GNUstep/ folder and included the C:/GNUstep/bin/ and C:/GNUstep/msys/1.0/bin/ folders in the PATH environment variable.
I noticed that there are more than one gcc.exe files present on my system for three different programming language compilers and their parent folders are included in the PATH environment variable. So, the gcc command conflicted with those three executables and therefore, the path to the dll files become invalid.
So, I had to move the GNUstep's bin directory to the top of the PATH environment variable to ensure that the GNUstep's gcc executable is used. And now, everything works like a charm.

cmake always use my pc installed library instead of my target path

I get a project that was built for x86, and I am trying to make it work with mips. But I encounter problem when modifying the CMakelists.txt.
So here is the problem, the following code always use my PC's x86 library:
PKG_CHECK_MODULES(LIBCRYPTO REQUIRED libcrypto)
IF(LIBCRYPTO_FOUND)
INCLUDE_DIRECTORIES(${LIBCRYPTO_INCLUDE_DIRS})
LINK_DIRECTORIES(${LIBCRYPTO_LIB_DIRS})
ENDIF(LIBCRYPTO_FOUND)
I googled and found they always use system library first and can use find_package with NO_CMAKE_SYSTEM_PATH flag. But its not working and give me the following message. I don't know what its talking about..
Could not find a package configuration file provided by "libcrypto" with
any of the following names:
libcryptoConfig.cmake
libcrypto-config.cmake
Add the installation prefix of "libcrypto" to CMAKE_PREFIX_PATH or set
"libcrypto_DIR" to a directory containing one of the above files. If
"libcrypto" provides a separate development package or SDK, be sure it has
been installed.
My question is how to properly link a library to the path I assigned to and works like original piece of code?

How do I make a program think it was built under a different directory with cmake while cross-compiling?

I am trying to cross-compile a web server (Monkey-Server). My host environment is an Ubuntu 64 bit and the target environment is an has an arm architecture. All the dependencies are available in the folder.There is an option to make install too, but I thought building it locally on my host machine transferring the folder over to the embedded system was a smart move. I am able to compile successfully and run the web server on the target system, but it complains that it is not able to find the config file. The web server looks for the config file in the path where it was compiled on the host machine.
Example: It tries to open a folder that only exist on the host machine
ERROR: Cannot find/open /home/username/src/camera_root/monkey-server/conf/
But it should actually be looking for the config file in
/monkey-server/conf/
This is what my toolchain file looks like
Set(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER /home/username/src/compilerdir/arm-hisiv300-linux-uclibcgnueabi-gcc)
#SET(CMAKE_SYSROOT /home/username/src/camera_root)
#SET(CMAKE_FIND_ROOT_PATH /home/username/src/camera_root)
As you can see at the bottom of my toolchain file I have tried to set both sysroot and find_root_path without luck.
When I tried the SET(CMAKE_SYSROOT /home/username/src/camera_root) line I was unable to compile because the C compiler was unable to compile a simple test program.
How do I help the web server find it's own config file?
This is an old question and the OP has probably moved on by now, but for anyone else with the same problem, the Monkey has a --configdir and a --configserver switch to set the location of the configuration files as a workaround for this problem.

On UnsatisfiedLinkError, clarification needed

When building the project from command line using mvn clean install everything builds without any issues.
When running some tests that use precompiled C libraries from IntelliJ, tests fail with java.lang.UnsatisfiedLinkError
I may be completely off here, but does IntelliJ not see the .so file? Is so, how can it be added please?
Shared library fails to load with UnsatisfiedLinkError if:
it's not in the working directory configured in the test run configuration.
it's not in PATH environment (on Mac Terminal and GUI apps have different environment, see this answer). Run IDEA from the Terminal open -a /Applications/IntelliJ\ IDEA\ 12.app/ to make environment the same.
it's not in the location specified using -Djava.library.path VM option.
.so depends on some other library that is not found for any of the 1-3 reasons (or the dependency of that dependency is not found, etc).

MonkeyTalkIDE not found Java (JRE) / (JDK) virtual machine

I am trying to install MonkeyTalkIDE but show this error
A java Runtime Environment (JRE) or Java Development kit (JDK) must be available in order to run MonkeyTalkIDE. No Java virtual machine was found after searching the following locations: C:\Program Files\MonkeyTalkIDE\jre\bin\javaw.exe javaw.exe in your current PATH.
I am also set environment variable for java.
How can resolved problem?
Download a Java JDK here.
You might need to set JAVA_HOME to point to the directory where you install Java. (I'll assume you know how to do that.)
set JAVA_HOME=<directory-where-you-installed-JDK>
Add the path to the Java /bin directory to your PATH environment variable. (I'll assume you know how to do that.) If you do the second step, it'll be
PATH=%PATH%;%JAVA_HOME%\bin;