ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Cannot link libraries to CMakeLists.txt

asked 2020-04-22 20:28:29 -0500

rdhn gravatar image

updated 2020-04-23 08:27:29 -0500

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.

  1. LINK mentioning how to add .so file to CMakeLists.txt. Has a usueful link to ROS Wiki Using thrid party libs too!
  2. 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.

edit retag flag offensive close merge delete

Comments

1

Quick comment: this seems like a CMake problem. Not a ROS one.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-23 05:42:06 -0500 )edit

Could be, could be not. I am not sure at the moment.

rdhn gravatar image rdhn  ( 2020-04-23 06:32:49 -0500 )edit

This link solved my problem. I am able to build the package now.

rdhn gravatar image rdhn  ( 2020-04-23 08:26:09 -0500 )edit

So this was a CMake issue.

Please post your last edit as an answer and accept your own answer.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-23 08:40:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-23 10:16:41 -0500

rdhn gravatar image

THIS LINK solved my problem. I am able to build the package now.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-04-22 20:28:29 -0500

Seen: 632 times

Last updated: Apr 23 '20