cxx-qt icon indicating copy to clipboard operation
cxx-qt copied to clipboard

static linking/deployment?

Open CelestialCrafter opened this issue 1 year ago • 6 comments

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?

CelestialCrafter avatar Oct 15 '24 22:10 CelestialCrafter

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 avatar Oct 16 '24 09:10 ahayzen-kdab

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

CelestialCrafter avatar Oct 16 '24 13:10 CelestialCrafter

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

ahayzen-kdab avatar Oct 16 '24 13:10 ahayzen-kdab

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

LeonMatthesKDAB avatar Oct 16 '24 16:10 LeonMatthesKDAB

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

sounds good, thank you all!!

CelestialCrafter avatar Oct 16 '24 17:10 CelestialCrafter

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

ahayzen-kdab avatar Oct 17 '24 07:10 ahayzen-kdab