Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling error using make install to install OpenCV 4 in Raspbian Raspberry Pi 3+

`Hello, I have installed OpenCV on the Raspberry a couple of times. However, since everything is constantly evolving (OS, libraries, etc...). This time I am getting the following error:

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

I tried the following script:

    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

I expected the library to be compiled correctly, however, this is what the console shows:

-- 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`

Any help would be highly appreciated. I will backup and upload the image after compiling for the mental health of many people.

like image 742
Puértolas Luis Avatar asked Apr 04 '19 16:04

Puértolas Luis


1 Answers

I tried many things and solved the problem. The image of Raspbian Stretch + OpenCV 4 can be found here:

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

like image 196
Puértolas Luis Avatar answered Oct 17 '22 06:10

Puértolas Luis