You are not logged in.

#1 2019-06-01 22:29:53

jinpin
Member
Registered: 2019-05-15
Posts: 7

OpenCV: libraries are not linked by gcc

I have compiled my own OpenCV from the official and unmodified PKGBUILD.

After getting an error:

ImportError: libopencv_imgcodecs.so.4.1: cannot open shared object file: No such file or directory

I've found out that when building on machine gcc doesn't link the libraries and is only generating .a files:

...
opencv /usr/lib/libopencv_imgcodecs.a
opencv /usr/lib/opencv4/3rdparty/libade.a
..
opencv /usr/lib/pkgconfig/
opencv /usr/lib/pkgconfig/opencv4.pc
opencv /usr/lib/python2.7/
opencv /usr/lib/python2.7/site-packages/
opencv /usr/lib/python2.7/site-packages/cv2.so
opencv /usr/lib/python3.7/
opencv /usr/lib/python3.7/site-packages/
opencv /usr/lib/python3.7/site-packages/cv2.cpython-37m-x86_64-linux-gnu.so
...
usr/lib/libopencv_imgcodecs.so
usr/lib/libopencv_imgcodecs.so.4.1
usr/lib/libopencv_imgcodecs.so.4.1.0
...
usr/lib/pkgconfig/
usr/lib/pkgconfig/opencv4.pc
usr/lib/python3.7/
usr/lib/python3.7/site-packages/
usr/lib/python3.7/site-packages/cv2.cpython-37m-x86_64-linux-gnu.so

The difference comes from autodetected python2 and other autodetected libraries.
----

This error is reproducing in both my default environment and in a clean chroot. gcc works perfectly on any other compile job.

Last edited by jinpin (2019-06-01 22:32:02)

Offline

#2 2019-06-05 11:34:39

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,866

Re: OpenCV: libraries are not linked by gcc

llvm/clang also use cmake and show similar behaviour: if python2 is present, cmake defaults to that.

On archlinux /usr/bin/python points to python3 and cmake can be forced to use that.

Try adding

-D PYTHON_EXECUTABLE=/usr/bin/python \

to the cmake invocation.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB