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

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.

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.

Cannot get dependency to run in Intellij: UnsatisfiedLinkError

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)

Packaging Unreal Build Configurations

I have integrated the Steam API with my project and I had to add the actual API to the include directories of my DebugGame_Editor Configuration as well as the library directory.
The editor has been building properly for a month and Steam runs in-game, but now I have gotten to packaging my game and I am getting an error:
Cannot open include file: 'steam/steam_api.h': No such file or directory.
I assume that the configuration that it is using to package the game is missing those include directories and the library directory. Which configuration does UE4 use when packaging a game for Win64? There are like 40, and I don't want to try each and every one.
Engine Version: 4.7.6 from source (GitHub)
Edit:
I have gone through all configurations in the configuration manager in Visual Studio and added the two directories to the include and library sections of both Win32 and x64 in all of them (except the ones that say Mac or IOS), but no dice. It still throws that error message when it is trying to build ProjectName.generated.cpp
I'm not sure what to try next.
So I was able to fix this problem by including the files with an absolute path, rather than relying on relative include paths.

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;