conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
965 stars 1.77k forks source link

[question] windeployqt confusion #22693

Open stevenwdv opened 9 months ago

stevenwdv commented 9 months ago

What is your question?

Hello, I'm trying to compile and deploy a Qt6 application, and found some weird behavior. First, I install dependencies with a conanfile.py like the following:

from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout

class CompressorRecipe(ConanFile):
    settings = 'os', 'compiler', 'build_type', 'arch'

    def layout(self):
        cmake_layout(self)

    def generate(self):
        tc = CMakeDeps(self)
        tc.generate()

        tc = CMakeToolchain(self)
        tc.generate()

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def requirements(self):
        self.requires('qt/[^6.6.1]', options={
            'qtnetworkauth': True,
            'qtsvg': True,
            'qttranslations': True,
        })

    def build_requirements(self):
        self.tool_requires('qt/<host_version>', options={
            'qtnetworkauth': True,
            'qtsvg': True,
            'qttranslations': True,
            'qttools': True,
        })
conan install .\ -o:a qt/*:shared=True

(windeployqt doesn't work (or make sense, I guess?) with static libs.)

Then I build:

cmake --preset conan-default
cmake --build --preset conan-release

And then I try windeployqt:

.\build\generators\conanbuild.bat
windeployqt --dir .\artifacts\ .\build\mytarget\Release\myapp.exe

And this works fine.

However, if I use something like this: (which was the first thing I tried)

    def build_requirements(self):
        self.tool_requires('qt/<host_version>', options={
            # 'qtnetworkauth': True,
            # 'qtsvg': True,
            'qttranslations': True,
            'qttools': True,
        })

I get errors from windeployqt (running with --verbose 2):

Running: qtpaths -query
Trying to read translation catalogs from "C:/Users/StevenWdV/.conan2/p/b/qt4b8706bc8fb4b/p/res/datadir/translations/catalogs.json".
Found catalog "qtbase".
Found catalog "qtdeclarative".
Found catalog "qtmultimedia".
Found catalog "qtconnectivity".
Found catalog "qtlocation".
Found catalog "qtwebsockets".
Found catalog "qtserialport".
Found catalog "qtwebengine".
Found catalog "designer".
Found catalog "linguist".
Found catalog "assistant".
Found catalog "qt_help".
Found module "Qt6Concurrent".
  translation catalog: "qtbase"
Found module "Qt6Core".
  translation catalog: "qtbase"
Found module "Qt6Designer".
  plugin types: QList("designer")
Found module "Qt6DesignerComponents".
Found module "Qt6DeviceDiscoverySupport".
  translation catalog: "qtbase"
Found module "Qt6EntryPoint".
  translation catalog: "qtbase"
Found module "Qt6ExampleIcons".
  translation catalog: "qtbase"
Found module "Qt6FbSupport".
  translation catalog: "qtbase"
Found module "Qt6Gui".
  plugin types: QList("accessiblebridge", "platforms", "platforms/darwin", "xcbglintegrations", "platformthemes", "platforminputcontexts", "generic", "iconengines", "imageformats", "egldeviceintegrations")
  translation catalog: "qtbase"
Found module "Qt6Help".
Found module "Qt6Linguist".
Found module "Qt6Network".
  plugin types: QList("networkaccess", "networkinformation", "tls")
  translation catalog: "qtbase"
Found module "Qt6OpenGL".
  translation catalog: "qtbase"
Found module "Qt6OpenGLWidgets".
  translation catalog: "qtbase"
Found module "Qt6PrintSupport".
  plugin types: QList("printsupport")
  translation catalog: "qtbase"
Found module "Qt6QDocCatchConversionsPrivate".
Found module "Qt6QDocCatchGeneratorsPrivate".
Found module "Qt6QDocCatch".
Found module "Qt6Sql".
  plugin types: QList("sqldrivers")
  translation catalog: "qtbase"
Found module "Qt6Test".
  translation catalog: "qtbase"
Found module "Qt6Tools".
Found module "Qt6UiPlugin".
Found module "Qt6UiTools".
Found module "Qt6Widgets".
  plugin types: QList("styles")
  translation catalog: "qtbase"
Found module "Qt6Xml".
  translation catalog: "qtbase"
Qt binaries in C:\Users\StevenWdV\.conan2\p\b\qt4b8706bc8fb4b\p\bin
readPeExecutable: C:\pep\core\build\cpp\pep\assessor\Release\pepAssessor.exe 64 bit, dependent libraries: 32, release
Unable to find dependent libraries of C:\Users\StevenWdV\.conan2\p\b\qt4b8706bc8fb4b\p\bin\Qt6NetworkAuth.dll :Cannot open 'C:/Users/StevenWdV/.conan2/p/b/qt4b8706bc8fb4b/p/bin/Qt6NetworkAuth.dll': The system cannot find the file specified.

So it seems that Qt was/is looking for DLLs in the build package folder instead of the host package folder. Is this intentional? This seems weird to me. Does this still work when cross compiling?

Btw, I think it obtains the Qt DLL folder path from qtpaths.exe in the build package folder, which contains absolute paths put in there when this executable is built.

sabelka commented 9 months ago

I also noticed this some time ago, it looks like a bug to me.

And cross-compiling (at least Linux to Windows) with windeployqt is not supported (see here https://bugreports.qt.io/browse/QTBUG-77823?focusedCommentId=473297&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel )

stevenwdv commented 9 months ago

Btw, similarly it also failed when compiling the tools as static, while I would expect that only the runtime would need to be shared.

stevenwdv commented 8 months ago

Oh wait, it seems like crosscompiling qt is not actually supported yet... :/ See #20257 etc. https://github.com/conan-io/conan-center-index/blob/1c888e8686e4656c5046dd269045c713bd610d4e/recipes/qt/6.x.x/conanfile.py#L303-L304