Qt6 libraries/plugins deployment in cmake projects
Started to revive one my old Python extension projects recently: adding setup.py installation with CMake/Vcpkg based build, adding more libraries like OIIO, OCIO to go full throttle with image I/O and color spaces, adding OpenVDB to reimplement my old vdbtool (images to OpenVDB volume stacker) and finally adding Qt6 (since I wanted to try that crazy idea of making a Python3 extension with Qt6 C++ application inside. How about a video player as a Python3 extension?).
The main problem now is to deploy all Qt6 dependencies along with library and I can start with some more crazy GUI stuff.
And make sure it works from within setup.py.
So if you’ve ran into the situation like this:
python.exe -c "import ffmp; ffmp.qt()"
qt.core.plugin.factoryloader: checking directory path "C:/Vcpkg/installed/x64-windows/tools/python3/platforms" …
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
It mean Qt6 is unable to find it’s platform plugins (and you probably have half of dependencies missing anyways). So, the correct way to install that bundle is next:
https://www.qt.io/blog/cmake-deployment-api
https://doc-snapshots.qt.io/qt6-dev/qt-deploy-runtime-dependencies.html
(and it’s really new, article is dated Sept 02 2022)