Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » compile makefile and linker problems(No way to tell eclipse where to find libjvm.so)
icon4.gif  compile makefile and linker problems [message #1754951] Fri, 24 February 2017 07:42 Go to next message
Eclipse UserFriend
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!
Re: compile makefile and linker problems [message #1754967 is a reply to message #1754951] Fri, 24 February 2017 12:22 Go to previous messageGo to next message
Eclipse UserFriend
Are you attempting to mix a 64 and 32 bit library and objects?
Re: compile makefile and linker problems [message #1754988 is a reply to message #1754967] Fri, 24 February 2017 23:53 Go to previous message
Eclipse UserFriend
recipe for target 'src/JNItest1.o' failed. On element subdir.mk line 18, which reads: @echo 'Building file: $<'!
Is a Make error telling you that a recipe failed and the first recipe line number.
https://www.gnu.org/software/make/manual/html_node/Errors.html
$< is a Make macro for the name of the first prerequisite.
https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html
The actual error will appear before the recipe failed message.
A complete build log would be helpful.

The R_X86_64_PC32 message may be that error. It means that an offset was too large for the memory model in use.
The default for x86_64 uses signed 32-bit offsets.

https://www.eclipse.org/forums/index.php?t=msg&th=1078545&goto=1735476&#msg_1735476
http://stackoverflow.com/questions/10486116/what-does-this-gcc-error-relocation-truncated-to-fit-mean
https://tecnocode.co.uk/2014/10/01/dynamic-relocs-runtime-overflows-and-fpic/
http://stackoverflow.com/questions/33719825/how-to-resolve-relocation-truncated-to-fit-r-x86-64-pc32-against-undefined-sym
Google "R_X86_64_PC32" for more.

Fixing this would be generally off-topic for this forum. It's not a CDT problem. However, you may be able to fix it by modifying compile and link parameters within CDT.

[Updated on: Sat, 25 February 2017 14:58] by Moderator

Previous Topic:CDT Code Formatter not indenting
Next Topic:'Launch failed. Binary not found' after project is re-built
Goto Forum:
  


Current Time: Thu Jul 10 07:08:42 EDT 2025

Powered by FUDForum. Page generated in 0.04250 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top