+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

在Raspberry PI上安装基于C的python库(OpenCV2)时,如何处理内部编译器错误(cc1plus:gimplify)?

发布于2021-04-09 12:15     阅读(2568)     评论(0)     点赞(7)     收藏(5)


0

1

2

3

4

5

我一直在尝试在我的Raspberry PI 3B上安装适用于Python 3的OpenCV2库。我通过apt并使用来安装Python 3,从而开始了此过程pip3安装OpenCV。但是,该过程相当缓慢,并且有时会因安装而挂断。通常,它会在几个小时后释放自己,但是在取得更多进展后,它将引发并出现安装错误。昨天我发现一个bash脚本声称可以在Raspberry PI上安装OpenCV。我复制了脚本,对其进行了调试,然后运行了它。在到达脚本的CMake构建部分之前,它似乎工作正常。它以15%的速度将构建挂起了几个小时,释放了自己并继续构建,直到遇到内部编译器错误,此时编译器中止了安装。下面是我用来安装OpenCV和窗口输出的bash脚本。我不知道从哪里开始调试它,所以任何方向都将不胜感激。

安装Bash脚本

# installOpenCV.sh
echo "OpenCV installation by learnOpenCV.com"

cvVersion="master"

# Clean build directories
rm -rf opencv/build
rm -rf opencv_contrib/build

# Create directory for installation
mkdir installation
mkdir installation/OpenCV-"$cvVersion"

# Save current working directory
cwd=$(pwd)

sudo apt -y update
sudo apt -y upgrade

sudo apt -y remove x264 libx264-dev

## Install dependencies
sudo apt -y install build-essential checkinstall cmake pkg-config yasm
sudo apt -y install git gfortran
sudo apt -y install libjpeg8-dev libjasper-dev libpng12-dev

sudo apt -y install libtiff5-dev

sudo apt -y install libtiff-dev

sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
sudo apt -y install libxine2-dev libv4l-dev
cd /usr/include/linux
sudo ln -s -f ../libv4l1-videodev.h videodev.h
cd $cwd

sudo apt -y install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt -y install libgtk2.0-dev libtbb-dev qt5-default
sudo apt -y install libatlas-base-dev
sudo apt -y install libmp3lame-dev libtheora-dev
sudo apt -y install libvorbis-dev libxvidcore-dev libx264-dev
sudo apt -y install libopencore-amrnb-dev libopencore-amrwb-dev
sudo apt -y install libavresample-dev
sudo apt -y install x264 v4l-utils

# Optional dependencies
# sudo apt -y install libprotobuf-dev protobuf-compiler
# sudo apt -y install libgoogle-glog-dev libgflags-dev
# sudo apt -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

# Install python
sudo apt -y install python3-dev python3-pip
sudo -H pip3 install -U pip numpy
sudo apt -y install python3-testresources

cd $cwd
# Install virtual environment
python3 -m venv OpenCV-"$cvVersion"-py3
echo "# Vitual Environment Wrapper" >> ~/.bashrc
echo "alias workoncv-$cvVersion=\source $cwd/OpenCv-$cvVersion-py3/bin/activate" >> ~/.bashrc
source "$cwd"/OpenCV-"$cvVersion"-py3/bin/activate

################### For Python 3 ########################
Now install python libararies wihin this virtaul environment\
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=1024/g' /etc/dpyhs-swapfile
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
pip install numpy dlib
 quit vitual environment
deactivate

git clone https://github.com/opencv/opencv.git
cd opencv
git checkout $cvVersion
cd ..
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout $cvVersion

echo $cwd

cd $cwd/opencv
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D BUIL_opencv_python3=yes \
    -D CMAKE_INSTALL_PREFIX=$cwd/installation/OpenCV \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D WITH_TBB=ON \
    -D WITH_V4L=ON \
    -D OPENCV_PYTHON3_INSTALL_PATH=$cwd/OpenCV-$cvVersion-py3/lib/python3.5/site-packages \
    -D WITH_QT=ON \
    -D WITH_OPENGL=ON \
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
    -D BUILD_EXAMPLES=ON ..

make -j$(nproc)
make install

终端输出

Scanning dependencies of target opencv_test_core
[ 59%] Building CXX object modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o
[ 59%] Building CXX object modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_channels.cpp.o
[ 59%] Building CXX object modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_dft.cpp.o
during GIMPLE pass: dom
In file included from /home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts.hpp:125,
                 from /home/pi/Documents/OpenCVInstaller/opencv/modules/core/test/ocl/../test_precomp.hpp:7,
                 from /home/pi/Documents/OpenCVInstaller/opencv/modules/core/test/ocl/test_arithm.cpp:42:
/home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts/ts_gtest.h: In member function ‘bool testing::internal::CartesianProductGenerator4<T1, T2, T3, T4>::Iterator::AtEnd() const [with T1 = std::pair<perf::{anonymous}::MatDepth, perf::{anonymous}::MatDepth>; T2 = cvtest::ocl::Channels; T3 = int; T4 = bool]’:
/home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts/ts_gtest.h:16171:10: internal compiler error: Illegal instruction
     bool AtEnd() const {
          ^~~~~
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/core/CMakeFiles/opencv_test_core.dir/build.make:63: modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
during GIMPLE pass: slp
during GIMPLE pass: ivopts
In member function ‘virtual void opencv_test::ocl::Dft_Mat_Test::Body()’:
cc1plus: internal compiler error: in gimplify_expr, at gimplify.c:11391
In static member function ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const testing::internal::linked_ptr<testing::internal::ParameterizedTestCaseInfo<opencv_test::ocl::ExtractChannel>::TestInfo>*; _ForwardIterator = testing::internal::linked_ptr<testing::internal::ParameterizedTestCaseInfo<opencv_test::ocl::ExtractChannel>::TestInfo>*; bool _TrivialValueTypes = false]’:
cc1plus: internal compiler error: in gimplify_expr, at gimplify.c:11391
during GIMPLE pass: ifcombine
In static member function ‘static cv::GMetaArgs cv::detail::MetaHelper<K, std::tuple<_Elements ...>, Out>::getOutMeta(const GMetaArgs&, const GArgs&) [with K = cv::gapi::core::GDivRC; Ins = {cv::GScalar, cv::GMat, double, int}; Out = cv::GMat]’:
cc1plus: internal compiler error: in gimplify_expr, at gimplify.c:11391
0x76a43717 __libc_start_main
    /build/glibc-FUvrFr/glibc-2.28/csu/libc-start.c:308
0x76a41717 __libc_start_main
    /build/glibc-FUvrFr/glibc-2.28/csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
0x76a88717 __libc_start_main
    /build/glibc-FUvrFr/glibc-2.28/csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
make[2]: *** [modules/core/CMakeFiles/opencv_test_core.dir/build.make:89: modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_dft.cpp.o] Error 1
[ 59%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ocl/goclkernel.cpp.o
[ 59%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ocl/goclimgproc.cpp.o
make[2]: *** [modules/core/CMakeFiles/opencv_test_core.dir/build.make:76: modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_channels.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2784: modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2
make[2]: *** [modules/gapi/CMakeFiles/opencv_gapi.dir/build.make:674: modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/fluid/gfluidcore.cpp.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[2]: *** Waiting for unfinished jobs....
/home/pi/Documents/OpenCVInstaller/opencv/modules/gapi/src/backends/ocl/goclkernel.cpp: In member function ‘const cv::UMat& cv::GOCLContext::inMat(int)’:
/home/pi/Documents/OpenCVInstaller/opencv/modules/gapi/src/backends/ocl/goclkernel.cpp:14:34: internal compiler error: in gimplify_expr, at gimplify.c:11391
     return (inArg<cv::UMat>(input));
                                  ^
0x76b34717 __libc_start_main
    /build/glibc-FUvrFr/glibc-2.28/csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
make[2]: *** [modules/gapi/CMakeFiles/opencv_gapi.dir/build.make:700: modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ocl/goclkernel.cpp.o] Error 1
/home/pi/Documents/OpenCVInstaller/opencv/modules/gapi/src/backends/ocl/goclimgproc.cpp: In function ‘cv::gapi::GKernelPackage cv::gapi::imgproc::ocl::kernels()’:
/home/pi/Documents/OpenCVInstaller/opencv/modules/gapi/src/backends/ocl/goclimgproc.cpp:295:11: internal compiler error: in gimplify_expr, at gimplify.c:11391
         >();
           ^
0x76acd717 __libc_start_main
    /build/glibc-FUvrFr/glibc-2.28/csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
make[2]: *** [modules/gapi/CMakeFiles/opencv_gapi.dir/build.make:713: modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/ocl/goclimgproc.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:17223: modules/gapi/CMakeFiles/opencv_gapi.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
[  4%] Built target libwebp
[  5%] Built target libopenjp2
[  8%] Built target IlmImf
[ 10%] Built target libprotobuf
[ 11%] Built target quirc
[ 11%] Built target ittnotify
[ 12%] Built target ade
[ 12%] Built target opencv_videoio_plugins
[ 15%] Built target opencv_core
[ 17%] Built target opencv_imgproc
[ 18%] Built target opencv_imgcodecs
[ 19%] Built target opencv_videoio
[ 20%] Built target opencv_highgui
[ 21%] Built target opencv_ts
[ 21%] Building CXX object modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o
In file included from /home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts.hpp:18,
                 from /home/pi/Documents/OpenCVInstaller/opencv/modules/core/test/ocl/../test_precomp.hpp:7,
                 from /home/pi/Documents/OpenCVInstaller/opencv/modules/core/test/ocl/test_arithm.cpp:42:
/home/pi/Documents/OpenCVInstaller/opencv/modules/core/test/ocl/test_arithm.cpp: In member function ‘virtual void opencv_test::ocl::Lut_Mat_Test::TestBody()’:
/home/pi/Documents/OpenCVInstaller/opencv/modules/core/include/opencv2/core/utils/trace.hpp:164:82: internal compiler error: in gimplify_expr, at gimplify.c:11391
     const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
                                                                                  ^
/home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts/ts_ext.hpp:37:8: note: in expansion of macro ‘CV__TRACE_APP_FUNCTION_NAME’
        CV__TRACE_APP_FUNCTION_NAME(name); \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts/ts_ext.hpp:158:72: note: in expansion of macro ‘CV__TEST_BODY_IMPL’
     void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() BODY_IMPL( #test_case_name "_" #test_name ) \
                                                                        ^~~~~~~~~
/home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts/ts_ext.hpp:162:43: note: in expansion of macro ‘CV__TEST_P’
 #define TEST_P(test_case_name, test_name) CV__TEST_P(test_case_name, test_name, Body, CV__TEST_BODY_IMPL)
                                           ^~~~~~~~~~
/home/pi/Documents/OpenCVInstaller/opencv/modules/ts/include/opencv2/ts/ocl_test.hpp:367:20: note: in expansion of macro ‘TEST_P’
 #define OCL_TEST_P TEST_P
                    ^~~~~~
/home/pi/Documents/OpenCVInstaller/opencv/modules/core/test/ocl/test_arithm.cpp:99:1: note: in expansion of macro ‘OCL_TEST_P’
 OCL_TEST_P(Lut, Mat)
 ^~~~~~~~~~
0x76b2f717 __libc_start_main
    /build/glibc-FUvrFr/glibc-2.28/csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
make[2]: *** [modules/core/CMakeFiles/opencv_test_core.dir/build.make:63: modules/core/CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2784: modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
pi@raspberrypi:~/Documents/OpenCVInstaller $ 

解决方案


暂无回答

0

1

2

3

4

5

6



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接: https://www.pythonheidong.com/blog/article/927052/04ce4655521944d77b96/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

7 0
收藏该文
已收藏

评论内容:(最多支持255个字符)