Tag Archives: opencv3.4.16

[Solved] Ubuntu 18.04 Compile opencv-3.4.16 Error: “c++: internal compiler error: Killed (program cc1plus)”

Ubuntu 18.04 compiles opencv-3.4.16 with the command “make – J” and encounters the error “C + +: internal compiler error: killed (program cc1plus)”. In the system, there are 8 CPUs and 32GB memory, and 83 cc1plus processes are found. Check the help information of make, “- j [n], — jobs [= n] allow n jobs at once; infinite jobs with no arg.”, If there are no parameters, an unlimited number of worker processes are used. The previous command “make – J” can be compiled successfully on a 128GB server.

According to the following commands provided by C + +: internal compiler error, increase the switching space to 8GB. The same problem still exists.

#The size of count is the size of the increased swap space, 1M is the block size, so the space size is bs*count=8192MB
sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 
# format the space into swap format just now
sudo mkswap /swapfile 
chmod 0600 /swapfile  
#Use the swap space you just created
sudo swapon /swapfile

After increasing the size of swap space, the space of KIB swap listed by the top command increases.

~/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

Then use the command “make – J 16” to recompile and complete the task successfully.

Some information in case of error is as follows:

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