0
$\begingroup$

Rosanswers logo

I am getting an error from the linker when I attempt to run catkin_make run_tests_my_package`

The error I get is: /usr/bin/ld: cannot find -lmy_package collect2: error: ld returned 1 exit status

Under testing in my CMakelist.txt I have the following: catkin_add_gtest(${PROJECT_NAME}-test test/utest.cpp) if(TARGET ${PROJECT_NAME}-test) target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) endif()

include_directories(include ${catkin_INCLUDE_DIRS})

Am I missing something? do I need to use add_executable in my CMakelist.txt?

Another thing to mention is my workspace layout, it's arranged as follows: my_package/ bin/ build/ src/ my_class.h my_class.cpp test/ utest.cpp world/ CMakelist.txt

and inside utext.cpp I am referencing my_class.h list this #include "my_package/my_class.h

Full CMakelist.txt


Originally posted by Kurt on ROS Answers with karma: 1 on 2014-08-21

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The linker is complaining that my_package is not a library. Do you create a library named my_package in your CMakeLists.txt? (Including your FULL CMakeLists.txt would be useful here).


Originally posted by ahendrix with karma: 47576 on 2014-08-21

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Kurt on 2014-08-21:
Yeah, I'm not actually including a cpp, was just a typo. I don't think I am creating a library called my_package in my CMakelist.txt. Here is the full CMakelist.txt

Comment by ahendrix on 2014-08-21:
Wow... there's some unusual bits in there. If you're trying to write a test which tests the ActorLibrary, you should probably be linking it against the ActorLibrary in the same way that you link your primary executable.

Comment by Kurt on 2014-08-21:
Cool that seems to have worked, I've managed to build and the the tests by modifying the target_link_libraries to this target_link_libraries(${PROJECT_NAME}-test ActorLibrary ${catkin_LIBRARIES})

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.