# Opencv build issue with PyQt6

**URL:** https://forum.opencv.org/t/opencv-build-issue-with-pyqt6/19702
**Category:** Python
**Tags:** qt, build
**Created:** [January 6, 2025, 11:55pm UTC](https://forum.opencv.org/t/opencv-build-issue-with-pyqt6/19702 "2025-01-06T23:55:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Alan\_Miller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alan_miller/32/5560_2.png) [@Alan\_Miller](https://forum.opencv.org/u/Alan_Miller)
#### Post date: [January 6, 2025, 11:55pm UTC](https://forum.opencv.org/t/opencv-build-issue-with-pyqt6/19702/1 "2025-01-06T23:55:41Z")

</div>

I’m trying to build OpenCV 4 with QT 6.8.1 and OpenVino.

First I built Qt 6.8.1 and OpenVino locally

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

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

```auto
    -D WITH_QT=ON -D WITH_OPENGL=ON \
    -D QT_MAKE_EXECUTABLE=/opt/qt/6.8.1/bin/qmake \

```

The cmake output shows

```auto
-- 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 i`mport cv2` in a python script I got errors like:

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

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