
Hello.
I am trying to compile a custom package but I am getting some errors with CMake. The error is the following:
-- +++ processing catkin package: 'kate_global'
-- ==> add_subdirectory(kate_global)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- kate_global: 2 messages, 0 services
-- Configuring done
CMake Error at kate_global/CMakeLists.txt:140 (add_executable):
Cannot find source file:
catkin::rosconsole::wrapped-linker-option0
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
CMake Error at kate_global/CMakeLists.txt:140 (add_executable):
No SOURCES given to target: control_node_kate
-- Build files have been written to: /home/pi/catkin_ws/build
Invoking "cmake" failed
I don't know what is wrong so I attach here CMakeLists and the directory of the files of executables:
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(kate_global)
find_package(catkin REQUIRED COMPONENTS
controller_manager
diff_drive_controller
roscpp
rospy
message_generation
std_msgs
move_base
)
add_message_files(
FILES
enc_msg.msg
CAN.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package()
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(
control_node_kate src/kate_control_loop.cpp src/kate_hw_interface.cpp
${catkin_LIBRARIES}
)
target_link_libraries(
control_node_kate
${catkin_LIBRARIES}
)
install(TARGETS control_node_kate
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
Files listed
pi@raspberrypi:~/catkin_ws/src/kate_global/src $ ls -l
total 12
-rwxrwxrwx 1 pi pi 2450 Jun 11 12:53 kate_control_loop.cpp
-rwxrwxrwx 1 pi pi 8060 Jun 11 13:17 kate_hw_interface.cpp
I am working on Raspberry Pi OS (64 bits) using ROS Noetic.
Thanks in advance.
Best regards. Alessandro
Originally posted by Alessandro Melino on ROS Answers with karma: 113 on 2020-06-29
Post score: 0
Original comments
Comment by gvdhoorn on 2020-06-29:
Please remove all the comments from your CMakeLists.txt. They are not needed and make it unnecessarily long.
Comment by Alessandro Melino on 2020-06-29:
Done. Thanks for the advice.
Comment by Jayanth on 2020-06-29:
please refer to this answer
https://answers.ros.org/question/244489/multiple-files-in-one-add_executable/#:~:text=Among%20those%20multiple%20files%2C%20only,file%20has%20the%20main%20function.
Comment by Alessandro Melino on 2020-06-30:
Respect to that answer, just the control_loop.cpp has the main entry, the hw_interface.cpp is called by an include file. Maybe I have to delete the add_executable of hw_interface? By the way, I have other similar project with that two add_executable and it compiles, so I don't know what is going wrong in this project.