Static Qt dependencies



  • Hello,

    I am trying to understand what a static Qt build is actually giving me.

    First, some context. My apologies if it's a little long. I work in a hospital. We create in-house software to help with our daily tasks, so we are really our single client ! Because I have little control on the computers used in the hospital (IT has that control, I work in a department as a clinical medical physicist), the simplest approach to all our software deployment has traditionally been to static link everything we can and simply put the executable somewhere on the network and let everybody run that copy.

    I am trying to duplicate that with our latest application, the first one with a GUI using Qt. So I built a static version of Qt5 with quite a few skip commands to get the smallest libraries possible (making sure that what we need is there, of course). Then, I compiled our in-house software and linked statically to Qt (using CMake, don't know if that makes a difference, would think not).

    On first attempts, everything compiled, but nothing linked. I started Googling (normal reaction these days I think ;-) ) and have been for 2 days now. I have figured out that linking to Qt was not enough. I needed to find and link against the system libraries as well, for instance Carbon and Cocoa. [ Note : I work on OSX on my computer for development, but recompile and deploy to Windows for the hospital (thus Qt rocks for me !) ]

    Looking with otool -L, I can see that my executable does not actually link against a Qt library (so static linking of my application to Qt worked) but does require the system libraries (and a few others, but nothing Qt).

    I should also mention that even with the linking properly done, the executable won't work. That though, if I understand correctly, is because of the new platform plugin system.

    My questions are thus the following :

    1. When compiling Qt statically, am I right in saying that the system library symbols are not brought into the archive ? 2) If so, is there a way to bring those symbols in ? My guess is no, but I am no expert.
    2. Is using Qt Deploy supported with statically linked libraries ?
    3. Does someone here know if CMake can be used with Qt Deploy.

    Thanks for your time.

    Ghyslain


  • Lifetime Qt Champion

    Hi,

    1. Yes
    2. You don't need to
    3. What to you mean by Qt Deploy ?
    4. IIRC Should be through cpack

    Hope it helps



  • Hi,

    Thanks for your answer.

    1. I'm sure there are other ways to achieve my goal. It just seems like creating a completely static application is easier. Does not mean it's achievable, just seems easier. But OK, I don't need to and probably should move on. :-)

    2. Sorry. I hadn't realized that macdeployqt was not a general feature for every platform (i.e. there isn't a windeployqt and lindeployqt). My bad. I gather the only way is through otool, dependency walker and the likes.

    3. I am looking into CPack. Learning curve though, so I was wondering if it was the best solution. Seems it is.

    Well, thanks again for your time.


  • Lifetime Qt Champion

    You're welcome,

    1. Depending on how you want to distribute your application bundle on OS X you might hit the Apple rules wall. IIRC they rather like separated dynamic libraries with well defined scope e.g. ui, network etc. Also be aware that static linking has licensing implications.

    2. macdeployqt for OS X (hence the mac), windeployqt exists but having Dependency Walker at hand is better, there's also androiddeployqt IIRC.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.