Exercise3.1 CMakeList Error

Hello, I am working on exercise 3.1 and when I catkin_make I keep receiving this error. This is a copy of my SSH:

user:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install

Running command: “make cmake_check_build_system” in “/home/user/catkin_ws/build”

– Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
– Using CMAKE_PREFIX_PATH: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/kinetic
– This workspace overlays: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/kinetic
– Using PYTHON_EXECUTABLE: /usr/bin/python
– Using Debian Python package layout
– Using empy: /usr/bin/empy
– Using CATKIN_ENABLE_TESTING: ON
– Call enable_testing()
– Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
– Found gmock sources under ‘/usr/src/gmock’: gmock will be built
– Found gtest sources under ‘/usr/src/gmock’: gtests will be built
– Using Python nosetests: /usr/local/bin/nosetests-2.7
– catkin 0.7.18
– BUILD_SHARED_LIBS is on
– BUILD_SHARED_LIBS is on
– ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
– ~~ traversing 4 packages in topological order:
– ~~ - exercise_22
– ~~ - my_package
– ~~ - service_client_pkg
– ~~ - topic_publisher_pkg
– ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
– +++ processing catkin package: ‘exercise_22’
– ==> add_subdirectory(exercise_22)
– +++ processing catkin package: ‘my_package’
– ==> add_subdirectory(my_package)
– +++ processing catkin package: ‘service_client_pkg’
– ==> add_subdirectory(service_client_pkg)
CMake Error at service_client_pkg/CMakeLists.txt:152 (add_dependencies):
Cannot add target-level dependencies to non-existent target
“simple_service_client”.

The add_dependencies works for top-level logical targets created by the
add_executable, add_library, or add_custom_target commands. If you want to
add file-level dependencies see the DEPENDS option of the add_custom_target
and add_custom_command commands.

CMake Error at service_client_pkg/CMakeLists.txt:153 (target_link_libraries):
Cannot specify link libraries for target “simple_service_client” which is
not built by this project.

– Configuring incomplete, errors occurred!
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeError.log”.
Makefile:724: recipe for target ‘cmake_check_build_system’ failed
make: *** [cmake_check_build_system] Error 1
Invoking “make cmake_check_build_system” failed

Here are some pictures of my IDE and code:

I basically did the exact same steps as mentioned in the handbook, however, the file names I chose are not the same as given in the solution manual for package name and cpp file name

Hi @aw3645,

The problem seems to be that the CMakeLists.txt contains a reference to a file that does not exist, most likely because you used different file names. According to the error message, this problem is on line 152 of the CMakeLists.txt file:

CMake Error at service_client_pkg/CMakeLists.txt:152 (add_dependencies):
Cannot add target-level dependencies to non-existent target
“simple_service_client”.

Could you please check that out and let us know?

I think I named something wrong by accident. I changed Line 151 from service_client_pkg to simple_service_client. the former is my package name and later is my cpp file name. Seems to work now. Thanks

1 Like