Ubuntu 18.04 编译opencv-3.4.16,遇到错误“c++: internal compiler error: Killed (program cc1plus)”
Ubuntu 18.04 使用命令“make -j”编译opencv-3.4.16,遇到错误“c++: internal compiler error: Killed (program cc1plus)”。系统中,有8个CPU,32GB内存,发现有83个cc1plus进程。检查make的帮助信息,“-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.”,如果没有参数,会使用无限多的工作进程。之前命令“make -j”在有128GB的服务器上能编译成功。
按解决c++: internal compiler error提供的下列命令,增加交换空间到8GB,还是有同样问题。
#count的大小就是增加的swap空间的大小,1M是块大小,所以空间大小是bs*count=8192MB
sudo dd if=/dev/zero of=/swapfile bs=1M count=8192
#把刚才空间格式化成swap格式
sudo mkswap /swapfile
chmod 0600 /swapfile
#使用刚才创建的swap空间
sudo swapon /swapfile
增加后Swap空间的大小,top命令列出的KiB Swap的空间增大。
~/proj/slam$ top
top - 11:25:12 up 23:59, 7 users, load average: 24.55, 70.32, 66.93
Tasks: 495 total, 19 running, 400 sleeping, 0 stopped, 0 zombie
%Cpu(s): 95.5 us, 4.4 sy, 0.1 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32760356 total, 28245364 free, 3986600 used, 528392 buff/cache
KiB Swap: 9392120 total, 8107088 free, 1285032 used. 28321152 avail Mem
再使用命令“make -j 16”重新编译,成功完成任务。
出错情况下的部分信息如下:
[ 96%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_resize_bitexact.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_smooth_bitexact.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_templmatch.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_thresh.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_subdivision2d.cpp.o
[ 97%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_watershed.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/videoio/CMakeFiles/opencv_test_videoio.dir/build.make:110: recipe for target 'modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_ffmpeg.cpp.o' failed
make[2]: *** [modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_ffmpeg.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:590: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_math.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_math.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
modules/videoio/CMakeFiles/opencv_test_videoio.dir/build.make:62: recipe for target 'modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_camera.cpp.o' failed
make[2]: *** [modules/videoio/CMakeFiles/opencv_test_videoio.dir/test/test_camera.cpp.o] Error 4
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/build.make:494: recipe for target 'modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/test/test_fisheye.cpp.o' failed
make[2]: *** [modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/test/test_fisheye.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
modules/objdetect/CMakeFiles/opencv_objdetect.dir/build.make:212: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/qrcode.cpp.o' failed
make[2]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/qrcode.cpp.o] Error 4
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
CMakeFiles/Makefile2:3434: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/all' failed
make[1]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:110: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_bufferpool.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_bufferpool.cpp.o] Error 4
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
付汉杰 hankf@amd.com