0

Running on Ubuntu 22.04 as my host build machine.

If I install cmake with sudo apt update then sudo apt install cmake or sudo apt install catkin (since catkin includes cmake), my Buildroot build using cmake no longer can find my compiler. Why?

After running make in my buildroot project, the compiler is unknown:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/gabriel/dev/repos/my_repo/output/my_board/host/bin/ccache
-- Check for working C compiler: /home/gabriel/dev/repos/my_repo/output/my_board/host/bin/ccache - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/home/gabriel/dev/repos/my_repo/output/my_board/host/bin/ccache"

  is not able to compile a simple test program.

  It fails with the following output:
...

So, uninstalling cmake from my host via sudo apt remove cmake removes this problem, but then I get a new error when I run make in my Buildroot project:

CMake Error at CMakeLists.txt:8 (find_package):
  By not providing "FindTinyXML2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "TinyXML2",
  but CMake did not find one.

  Could not find a package configuration file provided by "TinyXML2" with any
  of the following names:

    TinyXML2Config.cmake
    tinyxml2-config.cmake

  Add the installation prefix of "TinyXML2" to CMAKE_PREFIX_PATH or set
  "TinyXML2_DIR" to a directory containing one of the above files.  If
  "TinyXML2" provides a separate development package or SDK, be sure it has
  been installed.

...but at least it can find my compiler now. Here is the output just prior to the error above, showing it now can find my gcc-11 "C compiler" and g++-11 "CXX compiler":

-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/gabriel/dev/repos/my_repo/output/my_board/host/bin/ccache - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/gabriel/dev/repos/my_repo/output/my_board/host/bin/ccache - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/gabriel/dev/repos/my_repo/output/my_board/build/host-rospack-2.6.2/devel
-- Using CMAKE_PREFIX_PATH: /home/gabriel/dev/repos/my_repo/output/my_board/host//opt/ros/indigo/;/home/gabriel/dev/repos/my_repo/output/my_board/host/usr
-- This workspace overlays: /home/gabriel/dev/repos/my_repo/output/my_board/host//opt/ros/indigo/
-- Found PythonInterp: /home/gabriel/dev/repos/my_repo/output/my_board/host/usr/bin/python (found version "3.8.2") 
-- Using PYTHON_EXECUTABLE: /home/gabriel/dev/repos/my_repo/output/my_board/host/usr/bin/python
-- Using default Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/gabriel/dev/repos/my_repo/output/my_board/build/host-rospack-2.6.2/test_results
-- Found gtest: gtests will be built
CMake Warning at /home/gabriel/dev/repos/my_repo/output/my_board/host/opt/ros/indigo/share/catkin/cmake/test/nosetests.cmake:96 (message):
  nosetests not found, Python tests can not be run (try installing package
  'python3-nose')
Call Stack (most recent call first):
  /home/gabriel/dev/repos/my_repo/output/my_board/host/opt/ros/indigo/share/catkin/cmake/all.cmake:147 (include)
  /home/gabriel/dev/repos/my_repo/output/my_board/host/opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:4 (find_package)


-- catkin 0.6.19
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: filesystem program_options system 
-- Found PythonLibs: /home/gabriel/dev/repos/my_repo/output/my_board/host/usr/lib/libpython3.8.so (found suitable version "3.8.2", minimum required is "3.8") 

What's going on here? I expect it to find my compiler in both cases, but it won't if I have cmake locally installed, and I expect it to find the tinyxml2 package, but it won't, even though tinyxml2 is locally installed, as I explain here.

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
  • I feel like there's got to be a better way to learn how to fix my build system than googling for days on end and staring at my Stack Overflow page hoping for a helpful comment or answer. – Gabriel Staples Jan 10 '23 at 23:20

1 Answers1

1

ros-cmake-modules contains FindTinyXML2.cmake and FindTinyXML.cmake modules. Have you installed the ros-cmake-modules package with sudo apt install ros-cmake-modules ?

Your CMAKE_PREFIX_PATH is /home/gabriel/dev/repos/my_repo/output/my_board/host//opt/ros/indigo/ and the operating system of your host build machine is Ubuntu 22.04. Ubuntu version and ROS version are co-dependent, so you have to choose a pair. ROS Noetic is the version of ROS that is compatible with Ubuntu 22.04.

You might be able to get ROS Indigo to work in Ubuntu 18.04 if you install it from source, but you'll most likely run into issues. This is because ROS distros target a specific Ubuntu version (or sometimes 2 versions). If you use a different Ubuntu version, most dependencies will have different versions as well and this will most likely lead to annoying issues. For Ubuntu 18.04, you're better off running ROS Melodic. source

In a comment to this answer you wrote that your current build system is on Ubuntu 18.04 which is going to be end of life in April, so you're moving to Ubuntu 22.04. ROS Noetic is the version of ROS that is compatible with Ubuntu 22.04 or alternatively you can install ROS 2 Humble on Ubuntu 22.04 instead of Noetic by following the instructions at Ubuntu (Debian) ROS 2 Documentation: Humble documentation.

karel
  • 5,489
  • 46
  • 45
  • 50
  • Thank you. Why ROS Indigo? Our current build system is on Ubuntu 18.04 and gcc-8/g++-8 and is pretty cemented there. I'm beginning the pioneering process to move to Ubuntu 22.04, and as usual with anything new, don't know what I'm doing. – Gabriel Staples Jan 11 '23 at 01:45
  • Starting off with the ROS packages from the default Ubuntu 22.04 repositories can be a valuable learning experience and save you a lot of time in the long run even if you plan on upgrading from ROS to ROS 2 eventually. ROS 2 will not be included in the upcoming Ubuntu 23.04 default repositories. – karel Jan 11 '23 at 02:17
  • I just tried `make` in buildroot after `sudo apt install ros-cmake-modules`, and it made no difference. The behavior and errors were identical to what I have in the question. I tried it with and without `cmake` manually installed and got the same errors as before. – Gabriel Staples Jan 11 '23 at 02:23
  • My test was on Ubuntu 22.04. i have something like 200 out of 400 modules built in 22.04, but this [rospack](https://github.com/ros/rospack) one in question is giving me particular difficulty. Tinyxml2 is its dependency. – Gabriel Staples Jan 11 '23 at 03:39