cmake error with catkin_make, ROS installation - cmake

I have created a workspace as catkin_ws. Then, catkin_make was run successful.
After I type catkin_create_pkg ros_basics_tutorials std_msgs rospy roscpp and then the all folders and files created in ros_basics_tutorials folder.
However After this command, I type cd catkin_ws
and then catkin_make
Below error is shown Cmake Error, Could NOT find cpp (missing: cpp_DIR), cmake_check_build_system' failed
Base path: /home/selcuk/catkin_ws
Source space: /home/selcuk/catkin_ws/src
Build space: /home/selcuk/catkin_ws/build
Devel space: /home/selcuk/catkin_ws/devel
Install space: /home/selcuk/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/selcuk/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/selcuk/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/selcuk/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/selcuk/catkin_ws/devel;/opt/ros/melodic
-- Using PYTHON_EXECUTABLE: /home/selcuk/python/anaconda2/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/selcuk/catkin_ws/build/test_results
CMake Error: Target gtest has dependency information when it shouldn't.
Your cache is probably stale. Please remove the entry
gtest_LIB_DEPENDS
from the cache.
CMake Error: Target gtest_main has dependency information when it shouldn't.
Your cache is probably stale. Please remove the entry
gtest_main_LIB_DEPENDS
from the cache.
CMake Error: Target gmock has dependency information when it shouldn't.
Your cache is probably stale. Please remove the entry
gmock_LIB_DEPENDS
from the cache.
CMake Error: Target gmock_main has dependency information when it shouldn't.
Your cache is probably stale. Please remove the entry
gmock_main_LIB_DEPENDS
from the cache.
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.14
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 2 packages in topological order:
-- ~~ - ros_basics_tutorials
-- ~~ - naoqi_driver
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'ros_basics_tutorials'
-- ==> add_subdirectory(ros_basics_tutorials)
-- Could NOT find cpp (missing: cpp_DIR)
-- Could not find the required component 'cpp'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "cpp" with any of
the following names:
cppConfig.cmake
cpp-config.cmake
Add the installation prefix of "cpp" to CMAKE_PREFIX_PATH or set "cpp_DIR"
to a directory containing one of the above files. If "cpp" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
ros_basics_tutorials/CMakeLists.txt:10 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/selcuk/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/selcuk/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:320: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
I couldn't solve? How can solve it?

The error was due to anathor project folder which i canceled under the catkin_ws. I deleted it and complied again. The error solved.

Related

How to reuse an interface library in another project?

I want to reuse an interface library in another project. I tried it with:
find_package(mylib CONFIG REQUIRED)
target_link_libraries(project mylib)
Which gives the error:
/usr/bin/ld: cannot find -lmylib
Which I do not understand because I want to use an interface library why there is a linker error?
I made a minimal example of the interface library and the consumer project. Based on this stackoverlow answer
Console output install library:
walde#localhost build]$ cmake .. ; cmake --build . ; sudo cmake --install .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/walde/projects/sandbox/cmake_get_target/myLib/build
-- Install configuration: ""
-- Up-to-date: /usr/local/lib/cmake/mylib/mylibTargets.cmake
-- Up-to-date: /usr/local/lib/cmake/mylib/mylibConfigVersion.cmake
-- Up-to-date: /usr/local/lib/cmake/mylib/mylibConfig.cmake
-- Up-to-date: /usr/local/include
-- Up-to-date: /usr/local/include/calc.hxx
-- Up-to-date: /usr/local/include/calc.cxx
-- Up-to-date: /usr/local/include/CMakeLists.txt
Console output consumer:
[walde#localhost build]$ cmake .. ; cmake --build .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/walde/projects/sandbox/cmake_get_target/use_my_lib_in_another_project/build
Consolidate compiler generated dependencies of target project
[ 50%] Linking CXX executable project
/usr/bin/ld: cannot find -lmylib
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/project.dir/build.make:97: project] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/project.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
[walde#localhost build]$
I want to reuse an interface library in another project. I tried it with:
find_package(mylib CONFIG REQUIRED)
target_link_libraries(project mylib)
Three things:
Absolutely never use target_link_libraries without a visibility specifier.
When exporting targets, always include a namespace (via the NAMESPACE argument to install(EXPORT)) so that the IMPORTED target name contains a :: sigil in it.
For consistency in the build and install trees, create an ALIAS target in the build with the same namespace prefix as your install will have.
The reason for (1) is that no-visibility is not the same as any of simply PRIVATE, INTERFACE, or PUBLIC, and it drops into a weird legacy compatibility mode when the styles are mixed. Absolutely always include the appropriate one of the three.
The reason for (2) is that names that contain :: are always interpreted as CMake targets. That would make the error you observed absolutely impossible. CMake would instead tell you that namespace::mylib doesn't exist and you could correct the typo.
When target_link_libraries gets a name without a :: sigil, it tries to find a target with the same name, but if that fails, then it forwards it on to the compiler driver with the -l flag (or equivalent).
For (3), consistency is nice and this will also help users of add_subdirectory or FetchContent switch between that and find_package more easily.

espidf COMPONENT_DIR

I'm trying to compile a simple Hello_world example using the Smooth component (https://github.com/PerMalmberg/Smooth), and get error: include could not find load file:
../lib/compiler_options.cmake.
It seems that COMPONENT_DIR is not set, but I'm not aware whether/where to set this, or where this should have been set.
I've been staring at this too long, and am not finding the (apparently) obvious problem. Anyone any thoughts?
ERROR
Note: You are using Python 3.8.0. Python 3 support is new, please report any problems you encounter. Search for 'Setting
the Python Interpreter' in the ESP-IDF docs if you want to use Python 2.7.
Checking Python dependencies...
Python requirements from C:\Esp32_tools\esp-idf-v3.3\requirements.txt are satisfied.
Running cmake in directory C:\Temp\esp\testCPP\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 --warn-uninitialized C:\Temp\esp\testCPP"...
Warn about uninitialized values.
-- Building for target esp32
-- ccache will be used for faster builds
CMake Error at C:/Temp/esp/testCPP/externals/smooth/smooth_component/CMakeLists.txt:21 (include):
include could not find load file:
../lib/compiler_options.cmake
Call Stack (most recent call first):
C:/Esp32_tools/esp-idf-v3.3/tools/cmake/scripts/expand_requirements.cmake:107 (include)
C:/Esp32_tools/esp-idf-v3.3/tools/cmake/scripts/expand_requirements.cmake:217 (expand_component_requirements)`
CMake Error at C:/Esp32_tools/esp-idf-v3.3/CMakeLists.txt:39 (message):
Failed to expand component requirements
VERSION
C:\Temp\esp\testCPP>cmake --version
cmake version 3.13.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
CMakeLists.txt
set(CMAKE_CXX_STANDARD 17)
if(${ESP_PLATFORM})
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# Include Smooth as a component
set(EXTRA_COMPONENT_DIRS
externals/smooth/smooth_component)
project(name_of_your_project)
else()
# Empty project when not building for ESP (i.e. when loading the project into an IDE with already configured tool chains for native Linux)
endif()```
CMake Error at C:/Esp32_tools/esp-idf-v3.3/CMakeLists.txt:39 (message):
Failed to expand component requirements
You are missing this line in CMakeLists.txt
https://github.com/espressif/esp-idf/blob/master/examples/get-started/hello_world/CMakeLists.txt#L3

Catkin cannot find gtest

Since yesterday none of my packages containing tests build. Catkin complains it cannot find gtest when using catkin_add_gtests(), since GTEST_FOUND is FALSE. You can see this in the error msg below, with the custom output I added to my CMakeLists. Up to yesterday, GTEST_FOUND was TRUE when catkin_add_gtests() was called.
This is the error I always get. In this case I'm trying to build a mockup package on a clean catkin workspace:
Errors << silly_pkg:cmake /home/paco/catkin_ws2/logs/silly_pkg/build.cmake.002.log
Not searching for unused variables given on the command line.
Re-run cmake no build system arguments
-- Using CATKIN_DEVEL_PREFIX: /home/paco/catkin_ws2/devel/.private/silly_pkg
-- Using CMAKE_PREFIX_PATH: /home/paco/catkin_ws2/devel;/opt/ros/kinetic
-- This workspace overlays: /home/paco/catkin_ws2/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/paco/catkin_ws2/build/silly_pkg/test_results
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.11
-- GTEST_FOUND: FALSE
CMake Warning at /opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake:149 (message):
skipping gtest 'test_silly_pkg' in project 'silly_pkg' because gtest was
not found
Call Stack (most recent call first):
/opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake:79 (_catkin_add_executable_with_google_test)
/opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake:28 (_catkin_add_google_test)
CMakeLists.txt:28 (catkin_add_gtest)
CMake Error at /home/paco/catkin_ws2/src/silly_pkg/CMakeLists.txt:33 (target_link_libraries):
Cannot specify link libraries for target "test_silly_pkg" which is not
built by this project.
-- Configuring incomplete, errors occurred!
See also "/home/paco/catkin_ws2/build/silly_pkg/CMakeFiles/CMakeOutput.log".
See also "/home/paco/catkin_ws2/build/silly_pkg/CMakeFiles/CMakeError.log".
cd /home/paco/catkin_ws2/build/silly_pkg; catkin build --get-env silly_pkg | catkin env -si /usr/bin/cmake /home/paco/catkin_ws2/src/silly_pkg --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/paco/catkin_ws2/devel/.private/silly_pkg -DCMAKE_INSTALL_PREFIX=/home/paco/catkin_ws2/install; cd -
I am using catkin 0.7.11, libgtest-dev 1.7.0 and cmake 3.5.1. I use ROS Kinetic with Ubuntu 16.04. The only thing I did yesterday was reinstalling ROS Kinetic, but the package versions are exactly the same. Did anybody have this problem? Do you have any ideas on what could be happening?
EDIT 3/09/18:
By comparing with a functional catkin+gtest workspace in a different computer, I found out that the main difference is in the results of /opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake. In the functional workspace, line 292 evaluates to TRUE (gtest/gmock is not a target) while in my workspace it evaluates to FALSE. This is because in my workspace running find_package(GMock QUIET) (line 287) sets gmock and gtest as imported targets, which does not happen in the other computer. Why is this different?
Thanks TikO for your help!
Since you wrote that cmake does not find the libraries and that you have reinstalled Kinetic, I assume that you have a freshly installed machine or wiped out gtest libraries by accident.
If you install libgtest-dev, you only get the sources which you need to build and install like this:
sudo apt-get install libgtest-dev
mkdir /tmp/gtest_build && cd /tmp/gtest_build
cmake /usr/src/gtest
make
#copy or symlink libgtest.a and ligtest_main.a to /usr/lib folder
sudo cp *.a /usr/lib
After this routine, you should be able to build again without cmake complaining.
Optional
If you have limited rights on your machine and you are not allowed to install the libraries in that way, just copy them into some home folder like
mkdir ~/lib && cp *.a ~/lib
But be aware of the fact, that you have to call catkin in the following way:
LIBRARY_PATH=~/lib GTEST_ROOT=~/lib catkin_make
LIBRARY_PATH tells the linker where to find the libraries, while GTEST_ROOT gives cmake the location hints for it's checks.
Reference: https://github.com/tik0/gtest_ros_example
SOLUTION FOUND
gmock and gtest were being set to imported target because the suggested manual compilation of libgtest had created a FindGMock.cmake file inside /usr/share/cmake-3.5/Modules. This file was being called by the find(GMock QUIET)
in catkin_add_gtests(), therefore setting the imported target. Just deleting FindGMock.cmake solved the issue.

ROS catkin_make: rebuild package(s)

I found out that I incorrectly named a dependency "std_msgs" as "std_msg".
So I fixed!, but wait, catkin still thinks that lawnbot_description is wants "std_msg" as a dependency even though I fixed the dependency:
<?xml version="1.0"?>
<package format="2">
<name>lawnbot_description</name>
<version>0.0.0</version>
<description>The lawnbot_description package</description>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
Error output when doing catkin_make --force-cmake:
Base path: /home/josiah/PycharmProjects/lawnbot_ws
Source space: /home/josiah/PycharmProjects/lawnbot_ws/src
Build space: /home/josiah/PycharmProjects/lawnbot_ws/build
Devel space: /home/josiah/PycharmProjects/lawnbot_ws/devel
Install space: /home/josiah/PycharmProjects/lawnbot_ws/install
####
#### Running command: "make cmake_check_build_system" in
"/home/josiah/PycharmProjects/lawnbot_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/josiah/PycharmProjects/lawnbot_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /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/josiah/PycharmProjects/lawnbot_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.6
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 8 packages in topological order:
-- ~~ - turtlebot3 (metapackage)
-- ~~ - turtlebot3_bringup
-- ~~ - turtlebot3_slam
-- ~~ - lawnbot_description
-- ~~ - lawnbot_gazebo
-- ~~ - turtlebot3_navigation
-- ~~ - turtlebot3_teleop
-- ~~ - turtlebot3_description
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin metapackage: 'turtlebot3'
-- ==> add_subdirectory(turtlebot3/turtlebot3)
-- +++ processing catkin package: 'turtlebot3_bringup'
-- ==> add_subdirectory(turtlebot3/turtlebot3_bringup)
-- +++ processing catkin package: 'turtlebot3_slam'
-- ==> add_subdirectory(turtlebot3/turtlebot3_slam)
-- +++ processing catkin package: 'lawnbot_description'
-- ==> add_subdirectory(lawnbot_description)
CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
Could not find a package configuration file provided by "std_msg" with any
of the following names:
std_msgConfig.cmake
std_msg-config.cmake
Add the installation prefix of "std_msg" to CMAKE_PREFIX_PATH or set
"std_msg_DIR" to a directory containing one of the above files. If
"std_msg" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
lawnbot_description/CMakeLists.txt:10 (find_package)
-- Could not find the required component 'std_msg'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "std_msg" with any
of the following names:
std_msgConfig.cmake
std_msg-config.cmake
Add the installation prefix of "std_msg" to CMAKE_PREFIX_PATH or set
"std_msg_DIR" to a directory containing one of the above files. If
"std_msg" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
lawnbot_description/CMakeLists.txt:10 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/josiah/PycharmProjects/lawnbot_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/josiah/PycharmProjects/lawnbot_ws/build/CMakeFiles/CMakeError.log".
Makefile:290: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
It still thinks that the lawnbot_description package wants "std_msg". Why is this so hard? It cant be this complicated to modify package information and update it.
I have found that there is a package called : catkin_tools clean, but why should I have to download an extra package to simply update my workspace?
I have tried:
-catkin_make
-catkin_make --force-cmake
- I have seen solutions that involve deleting entire build/devel directories which horrifies me. That seems like a ton of work just to add an 's' to the end of a name
I am worried that catkin clean lawnbot_description will just delete the entire package. Is this my best option?
Local lawnbot_description cmake file:
cmake_minimum_required(VERSION 2.8.3)
project(lawnbot_description)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msg # I am not supposed to edit this right??? I tried editing and it still does not work
)
I found that editing the CMakeLists fixes the problem. However it is annoying that I need to change the package.xml and the CMakeLists to indicate a change in dependencies.
I thought that if I fix the package.xml the CMakeLists would be updated.
So future reference, edit the CMakeLists in your package to reflect changes made to the package. catkin_make will not do this for you it seems.
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msg
)
Should be:
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
Along with updating the package.xml

CMake can not find cm256cc, although it is installed in the root

Please take a look at the code below. Kindly tell me what I am doing wrong. Where do I need to install the cm256cc ?
I installed cm256cc via git clone in the root folder. Also git cloned sdrdaemon in the root. Any help is greatly appreciated.
root#beaglebone:~# ls
Desktop cm256cc sdrdaemon
root#beaglebone:~# cd sdrdaemon/
root#beaglebone:~/sdrdaemon# cd build/
root#beaglebone:~/sdrdaemon/build# cmake ..
-- Architecture: armv7l
-- Use g++ NEON SIMD instructions
-- Boost version: 1.55.0
-- checking for module 'libcm256cc'
-- package 'libcm256cc' not found
-- CM256cc not found
-- Could NOT find CM256CC (missing: CM256CC_LIBRARIES CM256CC_INCLUDE_DIR)
-- checking for module 'libairspy'
-- package 'libairspy' not found
-- libairspy not found
-- checking for module 'libbladerf'
-- package 'libbladerf' not found
-- libbladerf not found
-- checking for module 'libhackrf'
-- package 'libhackrf' not found
-- libhackrf not found
-- Found librtlsdr: /usr/include, /usr/lib/arm-linux-gnueabihf/librtlsdr.so
-- Found libusb: /usr/include/libusb-1.0, /usr/lib/arm-linux-gnueabihf/libusb-1.0.so
-- Found libnanomsg: /usr/include, /usr/lib/arm-linux-gnueabihf/libnanomsg.so
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CM256CC_INCLUDE_DIR (ADVANCED)
used as include directory in directory /root/sdrdaemon
used as include directory in directory /root/sdrdaemon
used as include directory in directory /root/sdrdaemon
used as include directory in directory /root/sdrdaemon
used as include directory in directory /root/sdrdaemon
-- Configuring incomplete, errors occurred!
See also "/root/sdrdaemon/build/CMakeFiles/CMakeOutput.log".
See also "/root/sdrdaemon/build/CMakeFiles/CMakeError.log".