undefined reference cmake [closed]

asked 2013-03-22 02:08:16 -0500

aps40 gravatar image


I'm trying link my own library in ros, which .cpp is in lib folder and the .h is in include folder. My folder schema is:

---- Program.cpp
---- MyLib.cpp
---- MyLib.h

I have create the next cmake:

cmake_minimum_required(VERSION 2.4.6)



find_package(PCL 1.6 REQUIRED)
message("PCL:" ${PCL_INCLUDE_DIRS})


rosbuild_add_library(MyLib lib/MyLib.cpp)

rosbuild_add_executable(Program src/Program.cpp)
target_link_libraries(Program MyLib ${PCL_LIBRARIES})

When I excute rosmake it show next error:

   src/Program.cpp:34: undefined reference to function....

The function that is not referenced is in MyLib, whoever rosmake has create libMyLib.o in lib folder.

If I writte the code of methods in MyLib.h instead of in MyLib.cpp I haven't this error.

Can anyone help me?


edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2013-05-27 09:15:17


I can't see why off-hand, but why don't you post the results of CDing into the build folder and running "VERBOSE=1 make" (without quotes) - that should help anyone help you.

DamienJadeDuff gravatar image DamienJadeDuff  ( 2013-03-22 02:46:02 -0500 )edit

Also, I'm not sure how it could be relevant, but why don't you try moving MyLib.cpp out of the lib/ folder and into a different one, as lib/ normally receives the binary library files (e.g. MyLib.so).

DamienJadeDuff gravatar image DamienJadeDuff  ( 2013-03-22 03:10:50 -0500 )edit