I’m trying to build OpenCV 4 with QT 6.8.1 and OpenVino.
First I built Qt 6.8.1 and OpenVino locally
> qmake --version
QMake version 3.1
Using Qt version 6.8.1 in /opt/qt/6.8.1/lib
> cat /opt/intel/openvino_2024.6.0/runtime/version.txt
2024.6.0-17404-4c0f47d2335-releases/2024/6
Then I built OpenCV 4 with:
export LDFLAGS="-L/opt/intel/openvino_2024.6.0/runtime/lib/arm64/Release -L/opt/onnx/onnxruntime/lib -L/opt/qt/6.8.1/lib"
export CPPFLAGS="-I/opt/intel/openvino_2024.6.0/runtime/include -I/opt/onnx/onnxruntime/include -I/opt/qt/6.8.1/include"
… and …
-D WITH_QT=ON -D WITH_OPENGL=ON \
-D QT_MAKE_EXECUTABLE=/opt/qt/6.8.1/bin/qmake \
The cmake output shows
-- GUI: QT6
-- QT: YES (ver 6.8.1 )
-- QT OpenGL support: YES (Qt6::OpenGL )
-- Cocoa: YES
-- OpenGL support: YES (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/OpenGL.framework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Deve
And it compiles but when I import cv2
in a python script I got errors like:
ImportError: dlopen(/Users/me/miniconda3/envs/opencv-venv/lib/python3.12/site-packages/cv2/python-3.12/cv2.cpython-312-darwin.so, 0x0002): Library not loaded: @rpath/QtGui.framework/Versions/A/QtGui
Referenced from: <27DBDEE9-4DDD-3A97-8F56-BB1095E9F5C1> /opt/opencv/lib/libopencv_cvv.4.10.0.dylib
So then I created symlinks in my ${OPENCV-INSTALL-DIR}/lib/
dir
to all the “framework” dirs in ${QT-INSTALL-DIR}/lib/
and so far it seems to work.
cd /opt/opencv/lib
while read fw ; do ln -s /opt/qt/6.8.1/lib/$fw $fw ; done < <(ls -1 /opt/qt/6.8.1/lib/ |grep framework)
Is that the proper way to fix this or am I missing something in the build steps?