报错:c++: fatal error: Killed signal terminated program cc1plus
c++: fatal error: Killed signal terminated program cc1plus
·
在ARM64位板子上测试软件时,编译了realsense相机的ROS2程序,编译过程中报错了,大概意思是系统内存耗尽,想到可能是自己选用的4G+32G的板子可能性能确实不够。
环境:Ubuntu22.04 aarch64
报错内容
forlinx@ok3588:~/realsense_ws$ source /opt/ros/humble/setup.bash
forlinx@ok3588:~/realsense_ws$ colcon build
[0.766s] WARNING:colcon.colcon_core.prefix_path.colcon:The path '/home/forlinx/Downloads/realsense_ws/install' in the environment variable COLCON_PREFIX_PATH doesn't exist
[0.767s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/forlinx/Downloads/realsense_ws/install/realsense2_description' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.767s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/forlinx/Downloads/realsense_ws/install/realsense2_camera' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.767s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/forlinx/Downloads/realsense_ws/install/realsense2_camera_msgs' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.767s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/forlinx/Downloads/realsense_ws/install/realsense2_description' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.767s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/forlinx/Downloads/realsense_ws/install/realsense2_camera' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.767s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/forlinx/Downloads/realsense_ws/install/realsense2_camera_msgs' in the environment variable CMAKE_PREFIX_PATH doesn't exist
Starting >>> realsense2_camera_msgs
Finished <<< realsense2_camera_msgs [11.0s]
Starting >>> realsense2_camera
Starting >>> realsense2_description
Finished <<< realsense2_description [1.85s]
[Processing: realsense2_camera]
--- stderr: realsense2_camera
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
gmake[2]: *** [CMakeFiles/realsense2_camera.dir/build.make:132: CMakeFiles/realsense2_camera.dir/src/ros_sensor.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
gmake[2]: *** [CMakeFiles/realsense2_camera.dir/build.make:104: CMakeFiles/realsense2_camera.dir/src/parameters.cpp.o] Error 1
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
gmake[2]: *** [CMakeFiles/realsense2_camera.dir/build.make:90: CMakeFiles/realsense2_camera.dir/src/base_realsense_node.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:159: CMakeFiles/realsense2_camera.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed <<< realsense2_camera [58.5s, exited with code 2]
Summary: 2 packages finished [1min 10s]
1 package failed: realsense2_camera
1 package had stderr output: realsense2_camera
错误原因分析
内存不足:编译过程中系统内存(RAM)耗尽,导致操作系统终止了编译进程(cc1plus 是 C++ 编译器的一部分)。在嵌入式设备(使用的 RK3588 开发板)上,内存资源有限,编译大型项目时容易出现这种情况。
解决方法
1.增加可用内存(已验证解决)
使用交换分区(swap):如果设备内存较小,可以创建临时交换分区来增加虚拟内存:
# 创建一个2GB的交换文件
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# 编译完成后可以关闭交换分区(可选)
# sudo swapoff /swapfile
# sudo rm /swapfile
做完上面这一步后编译成功。。。
2.减少并行编译任务
限制同时编译的线程数,减少内存占用:
colcon build --parallel-workers 1 # 只使用1个线程编译
更多推荐
所有评论(0)