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

static linking/deployment? #1102

Open
CelestialCrafter opened this issue Oct 15, 2024 · 6 comments
Open

static linking/deployment? #1102

CelestialCrafter opened this issue Oct 15, 2024 · 6 comments
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo

Comments

@CelestialCrafter
Copy link

hi! i'm trying to deploy my qt6 app but I cant really find out how i'm meant to deploy it. am i meant to statically link QT or make the user install qt6-devel. if i do need to statically link qt, how would i do that with cxx-qt?

@ahayzen-kdab
Copy link
Collaborator

This is ultimately a Qt deployment question, on some platforms you have tools such as on Windows there is windeployqt or on Linux there is linuxdeployqt. These scan the binary and bundle the required libraries into a package such as an exe or appimage.

If you are using CMake to build you application then this will be performed as normal as from a CMake perspective this is just a normal Qt executable, here you could also decide whether you want to link statically or dynamically etc.

If you are using Cargo we do not specify the rustc-link-lib kind which means by default it tries to link dynamically except when building a static executable.

Note that for a static build to work you'll also need to have installed Qt with static libraries available and follow any of the legal implications of this.

https://doc.qt.io/qt-6/deployment.html
https://doc.qt.io/qt-6/windows-deployment.html

@ahayzen-kdab ahayzen-kdab added the 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo label Oct 16, 2024
@CelestialCrafter
Copy link
Author

Does that mean there's no way to statically link via cargo without linuxdeployqt?

@ahayzen-kdab
Copy link
Collaborator

You may need to use a static target platform such as x86_64-unknown-linux-musl to trigger the "except when building a static executable." part of https://doc.rust-lang.org/rustc/command-line-arguments.html#option-l-link-lib

But I believe that the macOS builds when we have been using vcpkg are statically linking to Qt, as that vcpkg build of Qt is a static build that provides no dynamic libraries to link to. So that is the other route, have a version of Qt that is only only providing .a's.

Otherwise could be an option to add to CxxQtBuilder in the refactor to explicitly pass static to rustc-link-lib lines, cc @LeonMatthesKDAB

@LeonMatthesKDAB
Copy link
Collaborator

Yeah, sounds like we should make that a goal for 0.8

@CelestialCrafter
Copy link
Author

Yeah, sounds like we should make that a goal for 0.8

sounds good, thank you all!!

@ahayzen-kdab
Copy link
Collaborator

Lets leave this issue open to track that change for 0.8 :-)

@ahayzen-kdab ahayzen-kdab reopened this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo
Projects
None yet
Development

No branches or pull requests

3 participants