10

`你好,我已经在 Raspberry 上安装了几次 OpenCV。但是,由于一切都在不断发展(操作系统、库等)。这次我收到以下错误:

-- Installing: /usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so
CMake Error at modules/python2/cmake_install.cmake:61 (file):
  file RPATH_CHANGE could not write new RPATH:

    /usr/local/lib

  to the file:

    /usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so

  No valid ELF RPATH or RUNPATH entry exists in the file; Error reading ELF
  identification.
Call Stack (most recent call first):
  modules/cmake_install.cmake:162 (include)
  cmake_install.cmake:95 (include)


Makefile:83: recipe for target 'install' failed
make: *** [install] Error 1

我尝试了以下脚本:

    sudo apt-get upgrade
    sudo apt-get install -y build-essential cmake pkg-config
    sudo apt-get install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
    sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
    sudo apt-get install -y libxvidcore-dev libx264-dev
    sudo apt-get install -y libgtk2.0-dev
    sudo apt-get install -y libatlas-base-dev gfortran
    sudo apt-get install -y python2.7-dev python3-dev
    cd ~
    #wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip
    #unzip opencv.zip
    #wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip
    #unzip opencv_contrib.zip
    git clone https://github.com/opencv/opencv.git
    git clone https://github.com/opencv/opencv_contrib.git
    pip install numpy
    cd ~/opencv
    mkdir build
    cd build
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        -D INSTALL_PYTHON_EXAMPLES=ON \
        -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
        -D BUILD_EXAMPLES=ON ..

    make -j4
    sudo make install
    sudo ldconfig

我希望该库能够正确编译,但是,这是控制台显示的内容:

-- Up-to-date: /usr/local/lib/libopencv_stitching.so.4.1
-- Up-to-date: /usr/local/lib/libopencv_stitching.so
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/warpers.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/autocalib.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/blenders.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/camera.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/exposure_compensate.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/matchers.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/motion_estimators.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/seam_finders.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/timelapsers.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/util.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/util_inl.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stitching/detail/warpers_inl.hpp
-- Up-to-date: /usr/local/lib/libopencv_superres.so.4.1.0
-- Up-to-date: /usr/local/lib/libopencv_superres.so.4.1
-- Up-to-date: /usr/local/lib/libopencv_superres.so
-- Up-to-date: /usr/local/include/opencv4/opencv2/superres.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/superres/optical_flow.hpp
-- Up-to-date: /usr/local/lib/libopencv_tracking.so.4.1.0
-- Up-to-date: /usr/local/lib/libopencv_tracking.so.4.1
-- Up-to-date: /usr/local/lib/libopencv_tracking.so
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/feature.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/kalman_filters.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/onlineBoosting.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/onlineMIL.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/tldDataset.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/tracker.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/tracking/tracking.hpp
-- Up-to-date: /usr/local/lib/libopencv_stereo.so.4.1.0
-- Up-to-date: /usr/local/lib/libopencv_stereo.so.4.1
-- Up-to-date: /usr/local/lib/libopencv_stereo.so
-- Up-to-date: /usr/local/include/opencv4/opencv2/stereo.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stereo/descriptor.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stereo/matching.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stereo/quasi_dense_stereo.hpp
-- Up-to-date: /usr/local/include/opencv4/opencv2/stereo/stereo.hpp
-- Up-to-date: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py
-- Up-to-date: /usr/local/lib/python2.7/dist-packages/cv2/load_config_py2.py
-- Up-to-date: /usr/local/lib/python2.7/dist-packages/cv2/load_config_py3.py
-- Up-to-date: /usr/local/lib/python2.7/dist-packages/cv2/config.py
-- Installing: /usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so
CMake Error at modules/python2/cmake_install.cmake:61 (file):
  file RPATH_CHANGE could not write new RPATH:

    /usr/local/lib

  to the file:

    /usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so

  No valid ELF RPATH or RUNPATH entry exists in the file; Error reading ELF
  identification.
Call Stack (most recent call first):
  modules/cmake_install.cmake:162 (include)
  cmake_install.cmake:95 (include)


Makefile:83: recipe for target 'install' failed
make: *** [install] Error 1`

任何帮助将不胜感激。为了很多人的心理健康,我将编译后的图像备份并上传。

4

2 回答 2

3

我尝试了很多东西并解决了这个问题。Raspbian Stretch + OpenCV 4 的图像可以在这里找到:

https://drive.google.com/open?id=1UpHp4hR0_mCSU4OS2OLGzebA_4zyBdqf

于 2019-04-15T17:24:01.037 回答
0

我也遇到了这个错误,并且能够使用以下步骤解决它:

  1. 导航到您的OpenCV目录(cd ..从您的build目录运行)。

  2. 运行以下命令:

    python ./modules/python/src2/gen2.py ./build/modules/python_bindings_generator ./build/modules/python_bindings_generator/headers.txt`
    
  3. 导航回您的构建目录并sudo make install再次运行

假设您从目录运行cmake命令,这次它应该可以工作。build

于 2019-04-09T22:47:56.140 回答