构建根:如果我在主机上安装 cmake,cmake 找不到我的编译器来构建 CMake 项目



在Ubuntu 22.04上运行

如果我安装cmake与sudo apt update然后sudo apt install cmakesudo apt install catkin(因为catkin包括cmake),我的Buildroot构建使用cmake不再能找到我的编译器。为什么?

在我的buildroot项目中运行make后,编译器是未知的:

-- 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:
...

所以,通过sudo apt remove cmake从我的主机卸载cmake消除了这个问题,但是当我在我的builroot项目中运行make时,我得到了一个新的错误:

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.

…但至少它现在可以找到我的编译器了。下面是在错误之前的输出,显示它现在可以找到我的gcc-11 "C编译器"和g++-11 "CXX编译器":

-- 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") 

这是怎么回事?我希望它在这两种情况下都能找到我的编译器,但如果我在本地安装了cmake,它就不会找到,我希望它能找到tinyxml2包,但它不会,即使tinyxml2是在本地安装的,正如我在这里解释的那样。

ros-cmake-modules包含FindTinyXML2。cmake和FindTinyXML。cmake模块。你安装了ros-cmake-modules包和sudo apt install ros-cmake-modules吗?

你的CMAKE_PREFIX_PATH是/home/gabriel/dev/repos/my_repo/output/my_board/host//opt/ros/indigo/,你的主机构建机的操作系统是Ubuntu 22.04。Ubuntu版本和ROS版本是相互依赖的,所以你必须选择一对。ROS Noetic是与Ubuntu 22.04兼容的ROS版本。

如果你从源代码安装它,你可能能够让ROS Indigo在Ubuntu 18.04中工作,但你很可能会遇到问题。这是因为ROS发行版针对的是一个特定的Ubuntu版本(有时是两个版本)。如果你使用不同的Ubuntu版本,大多数依赖项也会有不同的版本,这很可能会导致令人讨厌的问题。对于Ubuntu 18.04,你最好运行ROS Melodic。<一口>

在这个回答的评论中,你写道你目前的构建系统是Ubuntu 18.04,它将在4月结束生命,所以你要转移到Ubuntu 22.04。ROS Noetic是与Ubuntu 22.04兼容的ROS版本,或者您可以按照Ubuntu (Debian) ROS 2 Documentation: Humble Documentation的说明在Ubuntu 22.04上安装ROS 2 Humble而不是Noetic。

相关内容

  • 没有找到相关文章

最新更新