Cannot link libraries to CMakeLists.txt
I have seen some similar questions on this forum but none of them worked for me so I am going to ask it here.
So I have a custom package that generates a library file (ATC3DGlib64.so) during compilation and stores it in /usr/lib64/
. This custom package is compiled using a makefile and I am trying to put this package in my ROS workspace.
Below are the actual two command that are executed from the makefile when I run
make -f makefile
and I want to put all these commands in a CMakeLists.txt
g++ -DLINUX -I/opt/3DGuidance.Rev.E.64/3DGuidanceAPI -fPIC -pthread -m64 -c GetSynchronousRecordSample.cpp
g++ -m64 GetSynchronousRecordSample.o /usr/lib64/ATC3DGlib64.so -o GetSynchronousRecord64
Essentially there is one .cpp file that needs to compiled and linked to the library file that is in the /usr/lib64/
.
I have tried to link the ATC3DGlib64.so file to my executable in the CMakeLists.txt in many ways but none of them have worked for me. I keep getting this error when I run catkin_make
/usr/bin/ld: cannot find -lATC3DGlib64
collect2: error: ld returned 1 exit status
From what I read online it seems these kind of errors generate when the path is wrong and/or name is wrong and/or the library is not installed. I doubt any of these are true in my case.
I have also tried to create a symbolic link between the original library file that is in /usr/lib64/
to my ${PROJECT_SOURCE_DIR}/lib/
folder by running
ln -s /usr/lib64/ATC3DGlib64.so ${PROJECT_SOURCE_DIR}/lib/
For code reference
I am attaching the makefile
(C:\fakepathmakefile.png) and my CMakeLists.txt
in parts (PART1:C:\fakepath\cmake_1.png, PART2:C:\fakepath\cmake_2.png, PART3:C:\fakepath\cmake_3.png, PART4:C:\fakepath\cmake_4.png).
If anyone knows whats going on or has suggestions on what to try then please reply. Thanks for reading!
Some useful links that have unfortunately not worked for me but might be useful to others.
- LINK mentioning how to add .so file to CMakeLists.txt. Has a usueful link to ROS Wiki Using thrid party libs too!
- Add target link dependences, for ATC3DG.ini file - StackOverflow LINK
I will add some more relevant links here soon...
UPDATE: THIS LINK solved my problem. I am able to build the package now.
Quick comment: this seems like a CMake problem. Not a ROS one.
Could be, could be not. I am not sure at the moment.
This link solved my problem. I am able to build the package now.
So this was a CMake issue.
Please post your last edit as an answer and accept your own answer.