在Ubuntu上安装Colcon

在Ubuntu上安装Colcon,ubuntu,Ubuntu,感谢您的帮助: 我只是想在运行ubuntu的虚拟机上安装Colcon,然后 我正在使用以下命令:colcon build--symlink install 我得到了这个错误: Starting >>> sick_scan2 --- stderr: sick_scan2 CMake Error at CMakeLists.txt:24 (find_package): By not providing "Findament_cmake.cmake" in CMAKE_MODULE

感谢您的帮助: 我只是想在运行ubuntu的虚拟机上安装Colcon,然后 我正在使用以下命令:
colcon build--symlink install
我得到了这个错误:

Starting >>> sick_scan2
--- stderr: sick_scan2
CMake Error at CMakeLists.txt:24 (find_package):
By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this 
project
has asked CMake to find a package configuration file provided by
"ament_cmake", but CMake did not find one.

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

ament_cmakeConfig.cmake
ament_cmake-config.cmake

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


---
Failed   <<< sick_scan2 [ Exited with code 1 ]

Summary: 0 packages finished [0.30s]
1 package failed: sick_scan2
1 package had stderr output: sick_scan2
开始>>>生病扫描2
---标准:病态扫描2
CMakeLists.txt:24处的CMake错误(查找包):
通过在cmake_模块_路径中不提供“Findament_cmake.cmake”
项目
已要求CMake查找由提供的包配置文件
“ament_cmake”,但cmake没有找到。
找不到“ament_cmake”提供的包配置文件
具有
下列任何名称:
ament_cmakeConfig.cmake
ament_cmake-config.cmake
将“ament_cmake”的安装前缀添加到cmake_prefix_路径或集合中
“ament_cmake_DIR”指向包含上述文件之一的目录。如果
“ament_cmake”提供了一个单独的开发包或SDK,请确保
已安装。
---

失败您似乎没有安装一些环境变量

当我试图用Colcon建立ROS2项目时,我也遇到了类似的问题。 但是,当我最初将我的环境(类似于
~ros2\u ws/install/setup.bash)
来源化时,它就变得很好了


另外,如果您的问题也与ROS有关,请不要忘记在构建:
之后将已安装的库添加到类路径。install/setup.bash

下面详细解释了答案