最近在0基础学习ROS,记录一下自己遇到的问题。
1.出现以下错误
CMake Error at learning_topic/CMakeLists.txt:172 (add_executable):
Cannot find source file:
src/turtle_spawn.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: turtle_spawn
CMake Error: Cannot determine link language for target "turtle_spawn".
-- Generating done
-- Build files have been written to: /home/milk/catkin_ws/build
Invoking "cmake" failed
原因以及解决办法:是因为我把
add_executable(turtle_spawn src/turtle_spawn.cpp)
target_link_libraries(turtle_spawn ${catkin_LIBRARIES})
添加到了错误的CMakeLists.txt里边,一定要添加到和.cpp代码一致的文件夹中的CMakeLists里。