Installation error of openCV 3.0.0

After using cmake command we are getting this compilation error :-

c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/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-4.8/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-4.8/README.Bugs> for instructions.
make[2]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc_pch_dephelp.dir/opencv_perf_imgproc_pch_dephelp.cxx.o] Error 4
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core_pch_dephelp.dir/opencv_perf_core_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
c++: internal compiler error: Killed (program cc1plus)
make[2]: *** [modules/videoio/CMakeFiles/opencv_perf_videoio_pch_dephelp.dir/opencv_perf_videoio_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/videoio/CMakeFiles/opencv_perf_videoio_pch_dephelp.dir/all] Error 2
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[1]: *** [modules/cudaarithm/CMakeFiles/opencv_test_cudaarithm_pch_dephelp.dir/all] Error 2c++: internal compiler error: Killed (program cc1plus)
make[1]: *** [modules/ml/CMakeFiles/opencv_test_ml_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
virtual memory exhausted: Cannot allocate memory
make[2]: *** [modules/cudaarithm/CMakeFiles/opencv_perf_cudaarithm_pch_dephelp.dir/opencv_perf_cudaarithm_pch_dephelp.cxx.o] Error 4make[2]: *** [modules/calib3d/CMakeFiles/opencv_test_calib3d_pch_dephelp.dir/opencv_test_calib3d_pch_dephelp.cxx.o] Error 4
make[2]: *** [modules/features2d/CMakeFiles/opencv_test_features2d_pch_dephelp.dir/opencv_test_features2d_pch_dephelp.cxx.o] Error 4make[1]: *** [modules/cudaarithm/CMakeFiles/opencv_perf_cudaarithm_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/calib3d/CMakeFiles/opencv_test_calib3d_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/features2d/CMakeFiles/opencv_test_features2d_pch_dephelp.dir/all] Error 2
make[2]: *** [modules/features2d/CMakeFiles/opencv_perf_features2d_pch_dephelp.dir/opencv_perf_features2d_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/features2d/CMakeFiles/opencv_perf_features2d_pch_dephelp.dir/all] Error 2
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[1]: *** [modules/objdetect/CMakeFiles/opencv_perf_objdetect_pch_dephelp.dir/all] Error 2
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
virtual memory exhausted: Cannot allocate memory
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/imgproc/test_precomp.hpp.gch/opencv_test_imgproc_Release.gch] Error 1
make[2]: *** [modules/cudawarping/CMakeFiles/opencv_test_cudawarping_pch_dephelp.dir/opencv_test_cudawarping_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/imgproc/CMakeFiles/pch_Generate_opencv_test_imgproc.dir/all] Error 2
make[2]: *** [modules/cudafilters/CMakeFiles/opencv_test_cudafilters_pch_dephelp.dir/opencv_test_cudafilters_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudawarping/CMakeFiles/opencv_test_cudawarping_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/cudafilters/CMakeFiles/opencv_test_cudafilters_pch_dephelp.dir/all] Error 2
make[2]: *** [modules/stitching/precomp.hpp.gch/opencv_stitching_Release.gch] Error 1
make[1]: *** [modules/stitching/CMakeFiles/pch_Generate_opencv_stitching.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)

make[1]: *** [modules/cudastereo/CMakeFiles/opencv_perf_cudastereo_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/cudawarping/CMakeFiles/opencv_perf_cudawarping_pch_dephelp.dir/all] Error 2
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudaoptflow/CMakeFiles/opencv_perf_cudaoptflow_pch_dephelp.dir/opencv_perf_cudaoptflow_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudaoptflow/CMakeFiles/opencv_perf_cudaoptflow_pch_dephelp.dir/all] Error 2
make[2]: *** [modules/cudabgsegm/CMakeFiles/opencv_test_cudabgsegm_pch_dephelp.dir/opencv_test_cudabgsegm_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cuda/CMakeFiles/opencv_perf_cuda_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/cudabgsegm/CMakeFiles/opencv_test_cudabgsegm_pch_dephelp.dir/all] Error 2
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudacodec/CMakeFiles/opencv_perf_cudacodec_pch_dephelp.dir/opencv_perf_cudacodec_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudacodec/CMakeFiles/opencv_perf_cudacodec_pch_dephelp.dir/all] Error 2
virtual memory exhausted: Cannot allocate memory
c++: internal compiler error: Killed (program cc1plus)
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudaimgproc/CMakeFiles/opencv_test_cudaimgproc_pch_dephelp.dir/opencv_test_cudaimgproc_pch_dephelp.cxx.o] Error 4
make[2]: *** [modu*** [modules/cudaimgproc/CMakeFiles/opencv_test_cudaimgproc_pch_dephelp.dir/all] Error 2
make[1]: *** [modules/cudafilters/CMakeFiles/opencv_perf_cudafilters_pch_dephelp.dir/all] Error 2
make[2]: *** [modules/superres/perf_precomp.hpp.gch/opencv_perf_superres_Release.gch] Error 1
make[1]: *** [modules/superres/CMakeFiles/pch_Generate_opencv_perf_superres.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudaimgproc/CMakeFiles/opencv_perf_cudaimgproc_pch_dephelp.dir/opencv_perf_cudaimgproc_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudaimgproc/CMakeFiles/opencv_perf_cudaimgproc_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudacodec/CMakeFiles/opencv_test_cudacodec_pch_dephelp.dir/opencv_test_cudacodec_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudacodec/CMakeFiles/opencv_test_cudacodec_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cuda/CMakeFiles/opencv_test_cuda_pch_dephelp.dir/opencv_test_cuda_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cuda/CMakeFiles/opencv_test_cuda_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudastereo/CMakeFiles/opencv_test_cudastereo_pch_dephelp.dir/opencv_test_cudastereo_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudastereo/CMakeFiles/opencv_test_cudastereo_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudabgsegm/CMakeFiles/opencv_perf_cudabgsegm_pch_dephelp.dir/opencv_perf_cudabgsegm_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudabgsegm/CMakeFiles/opencv_perf_cudabgsegm_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudafeatures2d/CMakeFiles/opencv_perf_cudafeatures2d_pch_dephelp.dir/opencv_perf_cudafeatures2d_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudafeatures2d/CMakeFiles/opencv_perf_cudafeatures2d_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudaoptflow/CMakeFiles/opencv_test_cudaoptflow_pch_dephelp.dir/opencv_test_cudaoptflow_pch_dephelp.cxx.o] Error 4
make[1]: *** [modules/cudaoptflow/CMakeFiles/opencv_test_cudaoptflow_pch_dephelp.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/flann/precomp.hpp.gch/opencv_flann_Release.gch] Error 4
make[1]: *** [modules/flann/CMakeFiles/pch_Generate_opencv_flann.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/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-4.8/README.Bugs> for instructions.
make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 4
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2
make[2]: *** [modules/cudaarithm/precomp.hpp.gch/opencv_cudaarithm_Release.gch] Error 4
make[1]: *** [modules/cudaarithm/CMakeFiles/pch_Generate_opencv_cudaarithm.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/imgproc/precomp.hpp.gch/opencv_imgproc_Release.gch] Error 4
make[1]: *** [modules/imgproc/CMakeFiles/pch_Generate_opencv_imgproc.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/objdetect/test_precomp.hpp.gch/opencv_test_objdetect_Release.gch] Error 4
make[1]: *** [modules/objdetect/CMakeFiles/pch_Generate_opencv_test_objdetect.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/imgcodecs/precomp.hpp.gch/opencv_imgcodecs_Release.gch] Error 4
make[1]: *** [modules/imgcodecs/CMakeFiles/pch_Generate_opencv_imgcodecs.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudalegacy/precomp.hpp.gch/opencv_cudalegacy_Release.gch] Error 4
make[1]: *** [modules/cudalegacy/CMakeFiles/pch_Generate_opencv_cudalegacy.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/core/test_precomp.hpp.gch/opencv_test_core_Release.gch] Error 4
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_test_core.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudafilters/precomp.hpp.gch/opencv_cudafilters_Release.gch] Error 4
make[1]: *** [modules/cudafilters/CMakeFiles/pch_Generate_opencv_cudafilters.dir/all] Error 2

cc1plus: out of memory allocating 4194292 bytes after a total of 13836288 bytes
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudastereo/precomp.hpp.gch/opencv_cudastereo_Release.gch] Error 4
make[1]: *** [modules/cudastereo/CMakeFiles/pch_Generate_opencv_cudastereo.dir/all] Error 2
make[2]: *** [modules/cudabgsegm/precomp.hpp.gch/opencv_cudabgsegm_Release.gch] Error 1
make[1]: *** [modules/cudabgsegm/CMakeFiles/pch_Generate_opencv_cudabgsegm.dir/all] Error 2
virtual memory exhausted: Cannot allocate memory
make[2]: *** [modules/shape/precomp.hpp.gch/opencv_shape_Release.gch] Error 1
make[1]: *** [modules/shape/CMakeFiles/pch_Generate_opencv_shape.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/ml/precomp.hpp.gch/opencv_ml_Release.gch] Error 4
make[1]: *** [modules/ml/CMakeFiles/pch_Generate_opencv_ml.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/calib3d/precomp.hpp.gch/opencv_calib3d_Release.gch] Error 4
make[1]: *** [modules/calib3d/CMakeFiles/pch_Generate_opencv_calib3d.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/highgui/precomp.hpp.gch/opencv_highgui_Release.gch] Error 4
make[1]: *** [modules/highgui/CMakeFiles/pch_Generate_opencv_highgui.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/videoio/test_precomp.hpp.gch/opencv_test_videoio_Release.gch] Error 4
make[1]: *** [modules/videoio/CMakeFiles/pch_Generate_opencv_test_videoio.dir/all] Error 2

cc1plus: out of memory allocating 4194292 bytes after a total of 14069760 bytes
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/objdetect/precomp.hpp.gch/opencv_objdetect_Release.gch] Error 4
make[1]: *** [modules/objdetect/CMakeFiles/pch_Generate_opencv_objdetect.dir/all] Error 2
make[2]: *** [modules/calib3d/perf_precomp.hpp.gch/opencv_perf_calib3d_Release.gch] Error 1
make[1]: *** [modules/calib3d/CMakeFiles/pch_Generate_opencv_perf_calib3d.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/features2d/precomp.hpp.gch/opencv_features2d_Release.gch] Error 4
make[1]: *** [modules/features2d/CMakeFiles/pch_Generate_opencv_features2d.dir/all] Error 2

cc1plus: out of memory allocating 2416580 bytes after a total of 20742144 bytes
make[2]: *** [modules/videoio/precomp.hpp.gch/opencv_videoio_Release.gch] Error 1
make[1]: *** [modules/videoio/CMakeFiles/pch_Generate_opencv_videoio.dir/all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/cudalegacy/test_precomp.hpp.gch/opencv_test_cudalegacy_Release.gch] Error 4
make[1]: *** [modules/cudalegacy/CMakeFiles/pch_Generate_opencv_test_cudalegacy.dir/all] Error 2
make: *** [all] Error 2

Most probable causes are :

  • You’ve run out of memory. When using parallel make with -j4, you may get at some points 4 nvcc running that can use a lot of (too much) memory. You may see traces of that memory outage in dmesg output. You can safely retry make without -j4 and see if you get further.

  • You’ve run out of disk space. Building opencv takes a lot of disk, so I would advise to build it on a USB disk or SD card. You can check usage of your filesystems with

df -H

You can also try to disable precompiled headers in config (never enabled in my own experience).

I also notice you mention version 3.0.0. I’ve been building 3.1.0 and 3.2.0, but never 3.0.0.
If possible in your case, I’d suggest to go for 3.2.0 where many bugs have been fixed.