Important: Please read the Qt Code of Conduct -

Build statically linked app for mac

  • I am trying to follow the instructions here to build a statically linked app to distribute to my team members who do not have QT installed. (We are a golang shop). However; it is not working for me.

    it says

    cd /path/to/Qt
    ./configure -static <other parameters>
    make sub-src

    I have QT installed in ~/Qt.

    And if I go there I find a configure file in ~/Qt/5.12.7/src.

    I can run ./configure -static.

    I can't run make sub-src, that doesn't work but I can run just make. It takes a few hours to finish.

    I then open my project in QT Creator and set the build to release, then run Qmake from qt creator.

    I find a directory called build-appname-release in the same folder as source code. I can then go in there run

    make clean

    and I have an executable. When I run

    otool -L

    I see

    	@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.12.0, current version 5.12.7)
    	@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.12.0, current version 5.12.7)
    	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.12.0, current version 5.12.7)

    I assume this mean's it is not statically linked and if I give this to my teammates it will not work. What am I doing wrong

    TLDR: How can I produce a statically linked app from a simple QT project to distribute to my teammates who don't have QT installed. The current approach outlined in the docs don't seem to work.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The most straightforward is to keep using your dynamic build of Qt and use macdeployqt to prepare your bundle for distribution.

  • @SGaist Hey thanks that seems to work. I'm not sure what the -qmldir thing is about but it seems to work with Qt moved to another folder

  • Lifetime Qt Champion

    The qmldir option is to point the tool to your qml sources, if you use any, so that the corresponding dependencies are also deployed.

Log in to reply