Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to build static programs in Qt

How to build static programs in Qt

Scheduled Pinned Locked Moved Solved Installation and Deployment
5 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    El91
    wrote on last edited by
    #1

    Hi,

    I'd like to make my Qt compilation static ( no need to .dll files to run the .exe generated file) . I use MinGW and Qt 4.8.6 .

    I found some instructions about changing .conf files but I'm afraid it would take me a lot of time to correct it if I use the wrong one.

    So basically here are two versions :

    https://wiki.qt.io/How_to_build_a_static_Qt_version_for_Windows_with_gcc
    And
    http://wiki.batcom-it.net/index.php?title=Building_Qt_on_Windows_(MinGW)

    If I suppose the first one is good for me (if it is not, please tell me !) , I should do these changes :

    " edit the file Path-To-Qt-SDK\qt_static\mkspecs\win32-g+.conf and add the bold (with * ) marked stuff
    QMAKE_CFLAGS_RELEASE = -Os -momit-leaf-frame-pointer
    QMAKE_LFLAGS = -static -static-libgcc …
    DEFINES= QT_STATIC_BUILD

    edit Path-To-Qt-SDK\qt_static\qmake\Makefile.win32-g++
    LFLAGS = -static -static-libgcc …

    edit Path-To-Qt-SDK\qt_static\src\3rdparty\webkit\WebKit.pri
    add 'CONFIG = staticlib* on the top "

    So does "qt_static\mkspecs\win32-g+.conf" mean "qt_static\mkspecs\win32-g++\qmake.conf " or "qt_static\mkspecs\win32-g++-4.6\qmake.conf" ??

    And if it is the first one ( I mean "qt_static\mkspecs\win32-g++\qmake.conf " ) , should I replace the lines beginning with
    "QMAKE_CFLAGS_RELEASE =
    QMAKE_LFLAGS =
    DEFINES= "
    or should I keep them and add new ones ?

    And these "..." in "LFLAGS = -static -static-libgcc …" , should I keep it ??

    and then I have :
    "edit Path-To-Qt-SDK\qt_static\qmake\Makefile.win32-g++
    LFLAGS = -static -static-libgcc …"

    Here there is no doupt about the file (thank God) , so should I replace the line 30 "LFLAGS = -static-libgcc -s" with "LFLAGS = -static -static-libgcc …" ?? , and should I keep this "..." ?

    last but not least , we have :

    "edit Path-To-Qt-SDK\qt_static\src\3rdparty\webkit\WebKit.pri
    add 'CONFIG = staticlib* on the top "

    Unfortunately, there is no "WebKit.pri" in that location , I find it in "Path-To-Qt-SDK\qt_static\src\3rdparty\webkit\Source" , is it the right one ??

    And if itsn't , what would be the right one ?

    And please tell me how to add 'CONFIG = staticlib* on the top', does it mean I have to add "'CONFIG = staticlib*" in the beginning of the file, with that "*" ??

    Please I need answers from people who know precisely how to solve this issue, and forgive me about the need of details because I'm really tired of compiling and recompiling with no result and I'm still beginner.

    And after answering these questions , I'll be happy if you give me the right commands to enter in the Qt Command prompt.

    Thank you very much in advance !!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      First thing: do you really need webkit ? If no, then don't build it.

      Second thing: to ensure that the static build is working start by doing a standard static build i.e. call configure -static.

      Third thing: are you aware of the license implications of a static build ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        El91
        wrote on last edited by
        #3
        1. No I don't need webkit.
        2. I used standard static build before, and it worked successfully, the executable generated file works on my computer, but not in other computers (libgcc is not found or something like that). Now I deleted and installed again MinGW, Qt and Qt Creator.
        3. Yes, I'm aware.
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4
          1. Good, then just disable the build of webkit, it will save you time and space.
          2. That's normal, these are runtime libraries like the Visual Studio runtimes are needed when you deploy an application built with Visual Studio.

          The file is win32-g++/qmake.conf and yes change the lines.

          I'd also recommend an out of source build, since you are toying with the build settings. If something goes wrong you can simply nuke the build folder and start again otherwise you have to call make confclean each time before you reconfigure.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          E 1 Reply Last reply
          1
          • SGaistS SGaist
            1. Good, then just disable the build of webkit, it will save you time and space.
            2. That's normal, these are runtime libraries like the Visual Studio runtimes are needed when you deploy an application built with Visual Studio.

            The file is win32-g++/qmake.conf and yes change the lines.

            I'd also recommend an out of source build, since you are toying with the build settings. If something goes wrong you can simply nuke the build folder and start again otherwise you have to call make confclean each time before you reconfigure.

            E Offline
            E Offline
            El91
            wrote on last edited by
            #5

            @SGaist Yes ! , it worked, thank you very much !

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved