Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] qt/5.15.2: Plugins not deployed on MacOS #5487

Closed
MartinDelille opened this issue May 9, 2021 · 11 comments · Fixed by #5488
Closed

[package] qt/5.15.2: Plugins not deployed on MacOS #5487

MartinDelille opened this issue May 9, 2021 · 11 comments · Fixed by #5488
Labels
bug Something isn't working

Comments

@MartinDelille
Copy link
Contributor

I’m trying to use the conan version of Qt with the following conanfile.txt:

[requires]
qt/5.15.2

[options]
qt:shared=True
qt:qttools=True

[generators]
qt
virtualrunenv

When create a bundle application it crash on startup. I realized it was due to the missing plugins as you can see on this terminal output:

$ export QT_DEBUG_PLUGINS=1
$ ./test.app/Contents/MacOS/test
QFactoryLoader::QFactoryLoader() checking directory path "/Users/martin/Downloads/conan.app/Contents/MacOS/platforms" ...
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

The problem seems to come from the plugins folder location in the package subfolder (bin/archdatadir ).
The conan recipe offer the possibility to generate a qt.conf file containing information that should help my build chain to work properly:

[Paths]
Prefix = /Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200
ArchData = bin/archdatadir
HostData = bin/archdatadir
Data = bin/datadir
Sysconf = bin/sysconfdir
LibraryExecutables = bin/archdatadir/bin
Plugins = bin/archdatadir/plugins
Imports = bin/archdatadir/imports
Qml2Imports = bin/archdatadir/qml
Translations = bin/datadir/translations
Documentation = bin/datadir/doc
Examples = bin/datadir/examples 

For example, if I copy this file in the test.app/Contents/Resources folder, it works.
I also manage to make it work by manually moving the plugins folder from the bin/archdatadir package subfolder to the package folder (/Users/martin/.conan/data/qt/5.15.2///package/0af6aa42f3ece12447af62252e18e9680ffa1200).
What is the clean way to handle this issue ?

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: qt/5.15.2
  • Operating System+version: MacOS 10.15.7
  • Compiler+version: apple-clang 12.0
  • Docker image: N/A
  • Conan version: conan 1.36.0
  • Python version: Python 3.9.5

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

Configuration for profile default:

[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

  1. mkdir build && cd build
  2. conan install ..
  3. source activate_run.sh
  4. qmake ../test.pro
  5. make
  6. macdeployqt test.app -verbose=2

Logs (Include/Attach if Applicable)

Click to expand log
$ conan install ..
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

conanfile.txt: Installing package
Requirements
    brotli/1.0.9 from 'conan-center' - Cache
    bzip2/1.0.8 from 'conan-center' - Cache
    double-conversion/3.1.5 from 'conan-center' - Cache
    freetype/2.10.4 from 'conan-center' - Cache
    libiconv/1.16 from 'conan-center' - Cache
    libjpeg/9d from 'conan-center' - Cache
    libmysqlclient/8.0.17 from 'conan-center' - Cache
    libpng/1.6.37 from 'conan-center' - Cache
    libpq/12.2 from 'conan-center' - Cache
    odbc/2.3.7 from 'conan-center' - Cache
    opengl/system from 'conan-center' - Cache
    openssl/1.1.1j from 'conan-center' - Cache
    pcre2/10.35 from 'conan-center' - Cache
    qt/5.15.2 from 'conan-center' - Cache
    sqlite3/3.33.0 from 'conan-center' - Cache
    zlib/1.2.11 from 'conan-center' - Cache
    zstd/1.4.8 from 'conan-center' - Cache
Packages
    brotli/1.0.9:647afeb69d3b0a2d3d316e80b24d38c714cc6900 - Cache
    bzip2/1.0.8:75fe66fbfe61230e9fcbb361f13b6b3baa483e0a - Cache
    double-conversion/3.1.5:6a83d7f783e7ee89a83cf2fe72b5f5f67538e2a6 - Cache
    freetype/2.10.4:f4924bd3b94e155cbf790d74ba3a3c29ccc81e89 - Cache
    libiconv/1.16:647afeb69d3b0a2d3d316e80b24d38c714cc6900 - Cache
    libjpeg/9d:647afeb69d3b0a2d3d316e80b24d38c714cc6900 - Cache
    libmysqlclient/8.0.17:12e80b538837eca6e02ef1a3eed67aa25cf3423c - Cache
    libpng/1.6.37:88955cec2844f731470e07bd44ce5a3a24ec88b7 - Cache
    libpq/12.2:6615b55b95ff43a02a83c3955d071acd71dad079 - Cache
    odbc/2.3.7:5f4c4ed8ddf27bb70b22f93ac66b6827fc5411d1 - Cache
    opengl/system:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
    openssl/1.1.1j:647afeb69d3b0a2d3d316e80b24d38c714cc6900 - Cache
    pcre2/10.35:2d8245d819a6b7543095d62df5d99244060071ba - Cache
    qt/5.15.2:0af6aa42f3ece12447af62252e18e9680ffa1200 - Cache
    sqlite3/3.33.0:8ff459f4b248c0e0564ec4e80e52b8d1aca419ce - Cache
    zlib/1.2.11:647afeb69d3b0a2d3d316e80b24d38c714cc6900 - Cache
    zstd/1.4.8:647afeb69d3b0a2d3d316e80b24d38c714cc6900 - Cache

Installing (downloading, building) binaries...
brotli/1.0.9: Already installed!
bzip2/1.0.8: Already installed!
bzip2/1.0.8: Appending PATH environment variable: /Users/martin/.conan/data/bzip2/1.0.8/_/_/package/75fe66fbfe61230e9fcbb361f13b6b3baa483e0a/bin
double-conversion/3.1.5: Already installed!
libiconv/1.16: Already installed!
libiconv/1.16: Appending PATH environment var: /Users/martin/.conan/data/libiconv/1.16/_/_/package/647afeb69d3b0a2d3d316e80b24d38c714cc6900/bin
libjpeg/9d: Already installed!
opengl/system: Already installed!
openssl/1.1.1j: Already installed!
sqlite3/3.33.0: Already installed!
sqlite3/3.33.0: Appending PATH env var with : /Users/martin/.conan/data/sqlite3/3.33.0/_/_/package/8ff459f4b248c0e0564ec4e80e52b8d1aca419ce/bin
zlib/1.2.11: Already installed!
zstd/1.4.8: Already installed!
libmysqlclient/8.0.17: Already installed!
libpng/1.6.37: Already installed!
libpq/12.2: Already installed!
odbc/2.3.7: Already installed!
odbc/2.3.7: Appending PATH environment variable: /Users/martin/.conan/data/odbc/2.3.7/_/_/package/5f4c4ed8ddf27bb70b22f93ac66b6827fc5411d1/bin
pcre2/10.35: Already installed!
pcre2/10.35: Appending PATH environment variable: /Users/martin/.conan/data/pcre2/10.35/_/_/package/2d8245d819a6b7543095d62df5d99244060071ba/bin
freetype/2.10.4: Already installed!
qt/5.15.2: Already installed!
conanfile.txt: Generator virtualrunenv created activate_run.ps1
conanfile.txt: Generator virtualrunenv created deactivate_run.ps1
conanfile.txt: Generator virtualrunenv created environment_run.ps1.env
conanfile.txt: Generator virtualrunenv created activate_run.sh
conanfile.txt: Generator virtualrunenv created deactivate_run.sh
conanfile.txt: Generator virtualrunenv created environment_run.sh.env
conanfile.txt: Generator qt created qt.conf
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
$ source activate_run.sh
$ qmake ../test.pro
Info: creating stash file /Users/martin/dev/phonations/Bacasable/build/.qmake.stash
$ make
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.13 -Wall -Wextra -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Bacasable -I. -I../../../../.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/include -I../../../../.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/include/QtWidgets -I../../../../.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/include/QtGui -I../../../../.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/include/QtCore -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/AGL.framework/Headers -I../../../../.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/bin/archdatadir/mkspecs/macx-clang -o main.o ../main.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.13 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib -o test.app/Contents/MacOS/test main.o   /Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib/libQt5Widgets.dylib /Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib/libQt5Gui.dylib /Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib/libQt5Core.dylib -framework OpenGL -framework AGL
$ macdeployqt test.app -verbose=2
Log:
Log: Deploying Qt frameworks found inside: ("/Users/martin/dev/phonations/Bacasable/build/test.app/Contents/MacOS/test")
Log:  copied: "/Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib/libQt5Widgets.5.dylib"
Log:  to "test.app/Contents/Frameworks//libQt5Widgets.5.dylib"
Log:  copied: "/Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib/libQt5Gui.5.dylib"
Log:  to "test.app/Contents/Frameworks//libQt5Gui.5.dylib"
Log:  copied: "/Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/lib/libQt5Core.5.dylib"
Log:  to "test.app/Contents/Frameworks//libQt5Core.5.dylib"
Log:
Log: Deploying plugins from "/Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/plugins"
Log: Created configuration file: "test.app/Contents/Resources/qt.conf"
Log: This file sets the plugin search path to "test.app/Contents/PlugIns"
@MartinDelille MartinDelille added the bug Something isn't working label May 9, 2021
@MartinDelille
Copy link
Contributor Author

Maybe @ericLemanissier and @Minimonium (after reading #5129) might help on this issue ?

@MartinDelille
Copy link
Contributor Author

I dig into macdeployqt source code and don't understand how it can resolve the bin/archdatadir/plugins path.

@Minimonium
Copy link
Contributor

It uses the QLibraryInfo which can be overridden by the qt.conf. Can you verify that there is a correct qt.conf with correct pathes alongside the macdeployqt binary? It should be there for tools to work.

@MartinDelille
Copy link
Contributor Author

Yes I checked and I have the following qt.conf file in /Users/martin/.conan/data/qt/5.15.2/_/_/package/0af6aa42f3ece12447af62252e18e9680ffa1200/bin:

[Paths]
Prefix = ..
ArchData = bin/archdatadir
HostData = bin/archdatadir
Data = bin/datadir
Sysconf = bin/sysconfdir
LibraryExecutables = bin/archdatadir/bin
Plugins = bin/archdatadir/plugins
Imports = bin/archdatadir/imports
Qml2Imports = bin/archdatadir/qml
Translations = bin/datadir/translations
Documentation = bin/datadir/doc
Examples = bin/datadir/examples

@MartinDelille
Copy link
Contributor Author

Shouldn't Prefix be bin/archdatadir then ?

@Minimonium
Copy link
Contributor

Ah, I see the issue now. The macdeployqt explicitly assumes that the Plugins value is /plugins, which looks like a bug.

@MartinDelille
Copy link
Contributor Author

Yes. Should we move the plugins folder to the package root ?

@Minimonium
Copy link
Contributor

Minimonium commented May 9, 2021

Here:
https://github.com/qt/qttools/blob/5.15.2/src/macdeployqt/shared/shared.cpp#L977

deploymentInfo.qtPath = QLibraryInfo::location(QLibraryInfo::PrefixPath);

And here is the bug:

deploymentInfo.pluginPath = deploymentInfo.qtPath + "/plugins";

It should be

deploymentInfo.pluginPath = QLibraryInfo::location(QLibraryInfo::PluginsPath);

Or something like that. It's rather unfortunate that Qt doesn't do tests.

I'm not sure what was the motivation regarding the subdirectory, probably related to the CCI's convention about top-level directories. Could be either that or patching Qt to do support its own config file.

@MartinDelille
Copy link
Contributor Author

Yes I agree. I will submit the patch for the conan recipe and try to submit it to the upstream repo too.

Thanks for your help!

@MartinDelille
Copy link
Contributor Author

The patch works locally! 🎉

@prince-chrismc
Copy link
Contributor

Please link the PR 🙏

MartinDelille added a commit to MartinDelille/conan-center-index that referenced this issue May 9, 2021
@MartinDelille MartinDelille mentioned this issue May 9, 2021
4 tasks
conan-center-bot pushed a commit that referenced this issue Jun 1, 2021
* Patch macdeployqt fix #5487

* Update recipes/qt/5.x.x/patches/fix-macdeployqt.diff

Co-authored-by: ericLemanissier <ericLemanissier@users.noreply.github.com>

* QLibraryInfo::path => location

Co-authored-by: ericLemanissier <ericLemanissier@users.noreply.github.com>
madebr pushed a commit to madebr/conan-center-index that referenced this issue Jun 21, 2021
* Patch macdeployqt fix conan-io#5487

* Update recipes/qt/5.x.x/patches/fix-macdeployqt.diff

Co-authored-by: ericLemanissier <ericLemanissier@users.noreply.github.com>

* QLibraryInfo::path => location

Co-authored-by: ericLemanissier <ericLemanissier@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants