Qt 5.0.2 Static Linking Issues - Want to Build Standalone .exe



  • I'm new to Qt Creator and to application development. I've finished coding an application with Qt and would now like to make it into a standalone .exe file that I can use without Qt Creator or Visual Studio being installed. I have looked through multiple websites on how to do this. First, I think I'm supposed to build Qt statically, which I think I have done successfully. (Here is the link that I mainly have been referring to: http://doc-snapshot.qt-project.org/qt5-stable/qtdoc/deployment-windows.html) However, I cannot link my application with the libraries, and am unclear on how to do so, and, honestly, if that's even the next step. I think that I want there to be a "Build Static Release" option when I go to build my application, but again, I do not know how to do this.

    Also, when I downloaded Qt from their website, I also downloaded the source code zip file. I put them both into and folder and thought nothing of it. However I'm mentioning it because the deeper I dive into this issue the less I feel that I understand what I'm doing, lol.

    I am using:
    Qt 5.0.2
    Windows 7 - 64-bit
    MS Visual Studio 2012 compiler

    Any suggestions?


  • Moderators

    Did you install one of the pre-built version from the download page?
    If yes, you cannot make simply a static build of your application. You need to create a static version of Qt libs firsts.
    After this you can do also a static build of your application with those static Qt libs.

    However, beware of the license conditions they do not cover the static build.



  • I'm jumping in because I have the same basic problem. I thought that I had done a static build of Qt in the way that you are supposed to, and am unable to build a static .exe of my program. I've been messing with this for days...

    Are you saying that that one is not to use the downloads found here:
    http://qt-project.org/downloads
    If not, then what are you supposed to start with?


  • Moderators

    AFAIK those prebuilds are for dynamic linking only. I have not installed Qt 5.x pre-builds yet, but I do not see a reason why this should have changed.

    Basically you can use the dynamic build for your development and lateron for distribution of your application without problem. You need to add the required dlls to your exe then. During development when you are starting your application through Qt creator it is not difference.

    A static build give you one exe, but at the day's end there is no real advantage. In case you like to distribute your application later you might face a problem with the license when having a static build.

    When you like to to have a static build anyway, you need to do the compilations yourself. For windows you can "checkout this wiki":http://qt-project.org/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc for other OS you can find in the wiki also the guidelines on how to configure and compile. It takes a bit of time so.



  • So i solved my problem the last days.
    You can see my english thread here:
    https://qt-project.org/forums/viewthread/29271/

    And a complete list of my steps in german here:
    https://qt-project.org/forums/viewthread/29429/

    koahing gave me the german wiki and i think it's nearly the same. Of cause it's for the minGW compiler, but i think it's the same for VS. Just do you changes not in win32-g++ you need to find the VS mkspec.
    and you needn't use mingw32-make sub-src and the configuration needs to be different when saying -platform win32-g++ there you can just ignore the platform thing and build for all platforms.

    hope this helps you


Log in to reply
 

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