【问题标题】:Build fails during make of OpenCV on Raspberry Pi with "segmentation fault" caused by "cc1plus"在 Raspberry Pi 上构建 OpenCV 期间构建失败,“分段错误”由“cc1plus”引起
【发布时间】:2019-11-21 11:20:46
【问题描述】:

我正在尝试在我的 Raspberry Pi 3B+ 上构建 OpenCV 4.0.0,但一直遇到这个问题:

[ 83%] Building CXX object modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o

c++: internal compiler error: Segmentation fault (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/stitching/CMakeFiles/opencv_perf_stitching.dir/build.make:62: recipe for target 'modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o' failed
make[2]: *** [modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o] Error 4
CMakeFiles/Makefile2:23142: recipe for target 'modules/stitching/CMakeFiles/opencv_perf_stitching.dir/all' failed
make[1]: *** [modules/stitching/CMakeFiles/opencv_perf_stitching.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

这是我正在运行的脚本的 make/build 部分:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D PYTHON_EXECUTABLE=~/.virtualenvs/py3cv4/bin/python \
    -D WITH_GSTREAMER=ON \
    -D WITH_FFMPEG=ON \
    -D WITH_OPENMP=ON \
    -D BUILD_EXAMPLES=ON ..

echo ""
echo "======================="
echo "Building OpenCV..."
make -j4
sudo make install
sudo ldconfig

我在某处读到我应该将make -j4 命令更改为不使用所有四个内核,因为内存不足。我试过make -j1,但在同一个地方仍然出现同样的错误。我将使用简单的make 再试一次,但删除其中的所有预构建内容并从头开始,看看是否有帮助。

【问题讨论】:

    标签: opencv cmake raspberry-pi raspberry-pi3


    【解决方案1】:

    结果我需要完全删除我创建的构建并使用单个核心而不是全部四个来重建它,因为它占用了太多内存。我删除了我的/opencv/build/ 目录,然后在没有-j 命令的情况下执行了make,它运行良好。花了很长时间(5个多小时),但它确实成功完成了。现在我只需要弄清楚为什么我不能import cv2...

    【讨论】:

    • 我必须将cv2.cpython-XXXXXX-linux-gnu.so 符号链接到~/.virtualenvs/cv/lib/python3.6/site-packages/ 下的virtualenv 中,我还将它重命名为cv2.so。你可能会,或者可能已经做过类似的事情。
    猜你喜欢
    • 2019-12-08
    • 2015-01-12
    • 2021-04-16
    • 2015-06-15
    • 2019-09-24
    • 2018-12-01
    • 1970-01-01
    • 2022-11-02
    • 2020-11-27
    相关资源
    最近更新 更多