compile makefile and linker problems [message #1754951] |
Fri, 24 February 2017 12:42 |
Hans Missing name Messages: 3 Registered: December 2010 Location: Zurich |
Junior Member |
|
|
Here is my case:
Eclipse neon2 including java and c++ development
OS windows cygwin and/or SLES 11 or OpenSuse 42.2
Simple test Program using JNI to access can bus via c++ and the opposite. The latter just for test, accessing Java from c++.
On using:
g++ -std=c++0x -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L/usr/java/latest/jre/lib/amd64/server -ljvm -o JNItest1 ../src/JNItest1.cpp
On Linux and even on RaspberryPi I get a runable program. It is built, can be started and the output correspond to the expected result!
But I want more! Things will get more complicated, and I want to debug in an IDE. I just do not agree, to go more than 30 years back, when we used vi and shell to write and debug programs! And yes, in the last 20 years I did no c or c++. I did LotusScript and mostly Java! So certainly I ignore tricks which are common to c++ programmers.
The problem starts on doing a build with eclipse CDT. Should be the opposite, but it isn't!
On doing a build I get an error telling me "recipe for target 'src/JNItest1.o' failed" On element subdir.mk line 18, which reads: @echo 'Building file: $<'!
On deleting $< the error is gone! Just remember, it's eclipse generating the line not me!
Further I get an undefined reference to
jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
Yes, I know I must tell eclipse where to find libjvm.so!
I tried a hundred of variations. No chance!
Under Settings - GCC C++Linker Libraries - I set the path in this case: /usr/java/jdk1.8.0_121/jre/lib/amd64/server. This should go to -L. and I declared the library as jvm to obtain -ljvm! Doesen't work! I also tried the whole path like /usr/java/jdk1.8.0_121/jre/lib/amd64/server/libjvm.so. Doing so under Windows/cygwin, the error disapears, but then I get even worse:
relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_JNI_CreateJavaVM'
not really helpful! The LD_Library_PATH is set to point to libjvm.so! Remember, from the commandline the programm can be compiled and linked!
This is the end of my knowledge! Do any body have a hint, or know about some plans to fix the bug?
Meanwhile I'll go back 30 years into the past to study gdb!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02288 seconds