Important: Please read the Qt Code of Conduct -

Building static libraries

  • Hello all,
    I need all my exes to use static libraries instead of dlls. So I downloaded Qt libraries source: qt-everywhere-opensource-src-4.8.2.tar.gz

    I unpacked it to C:\Qt\4.8.2_static

    I followed these instructions: => I edited C:\Qt\4.8.2_static\mkspecs\win32-g++\qmake.conf , then ran C:\Qt\4.8.2_static\configure.exe -static -release -no-exceptions and then I coppied mingw32-make.exe to C:\Qt\4.8.2_static and ran it. After few hours build was done.

    In Qt Creator 2.4.1 I would like to add new version of Qt so I can use my static libraries => Tools -> Build & Run -> Qt Versions. It needs qmake.exe location, but I can't see any qmake.exe in C:\Qt\4.8.2_static. What I missed during building my static libraries?

    Please can you provide correct steps how to build static libraries and integrate them to my Qt Creator 2.4.1? I'm not an expert and I don't understand well the proccess of building static libraries, so please be patient with me.

    Thank you


  • its in the bin directory(c:\QT\4.8.2_static\bin\qmake.exe)

  • u don't need to put your mingw32-make into Qt build folder, if you have your MinGW (by the way what's the version of your gcc? try to ask the command gcc -v in command line), just make your MinGW into your PATH - open Start->My Computer preferences and see System Paths there->find PATH and put C:\MinGW\bin with ;

    then try to see qmake.exe in qmake folder and bin/ in your Qt build - can u see it? if you haven't got any troubles in compilation - it is strange that u don't have it

  • No, it is not, there is no exe nor dll in c:\QT\4.8.2_static\bin. Do I have to do again the build proccess? How should I modify it so qmake.exe is created?

  • well qmake is the first thing that is built...try this link

  • [quote author="gaminn" date="1340443863"]then I coppied mingw32-make.exe to C:\Qt\4.8.2_static and ran it. After few hours build was done.[/quote]
    this is a mistake...the build cannot have completed(or even started)...mingw32-make alone doesn't do anything(i think) need whole minGW compiler(instead of copying, you should add the path of mingw32-make to the PATH environment variable)...
    neways, i've tried building static libraries many times but some problem always crops up...and it doesn't have any advantage over distributing your program with dll's(except perhaps the no. of files to be given...but that problem can be easily overcome by packing all required files in a .zip or .msi package before distributing)....

  • I found out that in C:\QtSDK\Desktop\Qt\4.8.1\mingw\lib I have Qt static libs already compiled (there are files like libQtCore4.a, libQtGui4.a, ....). How can I tell compiler to link them?

    I edited C:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\win32-g++\qmake.conf
    QMAKE_LFLAGS = -static -static-libgcc
    but this is obviously not sufficient.

    What else should I do to link statically? Dependency Walker still shows dll dependecies of my exe.


  • those are not static libraries...ref to my earlier post, your static build was not completed

  • Libraries in C:\QtSDK\Desktop\Qt\4.8.1\mingw\lib are part of QtSdk-offline-win-x86-v1_2_1.exe installer (downloaded from, they weren't compiled by me. So I think I don't have to build them because I already have them. If I'm right there is only one thing I have to do - to instruct linker to link my Qt .pro project statically. Please help. Thank you.

  • the installer you used is the one i used builds dynamically linking Qt libs... to link statically you need to build static version of qt(instructions for which are given in the many links provided in earlier posts)

Log in to reply