Cannot make static application (Windows).



  • I successfully created static app with Qt4.5. Now I changed to 4.7 and I'm unable create it. I installed Qt on new machine and clearly followed all instructions from [url=http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc]this page[/url]. Qt assembled as static and I see libraries. Then I ported my project. It compiles as well but assembles as dynamically linked.

    Project consists of 2 parts: static library subproject and main application subproject. Following are settings for each project:

    Static library:
    QtCreator settings:
    [quote]Build configuration: Release
    Build steps\qmake\Additional arguments: -spec i:/qt/2010.05s/qt/mkspecs/win32-g++ CONFIG+=release CONFIG+=create_prl CONFIG+=static[/quote]

    At .pro file beginning:
    @
    static {
    CONFIG += staticlib
    DEFINES += STATIC
    message( "-----------STATIC-----------" )
    QMAKE_LFLAGS += -static
    }
    @

    Main application
    QtCreator settings:
    [quote]Build configuration: Release
    Build steps\qmake\Additional arguments: -spec i:/qt/2010.05s/qt/mkspecs/win32-g++ CONFIG+=link_prl CONFIG+=static (CONFIG+=release added automatically to effective qmake call)[/quote]

    At .pro file beginning:
    @
    static {
    CONFIG += static
    DEFINES += STATIC
    message( "-----------STATIC-----------" )
    QMAKE_LFLAGS += -static
    }
    @

    At the end of .pro file there is:
    @
    CONFIG( release, release|debug ) {
    LIBS += <path and name of static library>
    PRE_TARGETDEPS += <path and name of static library>
    message( "------------RELEASE------------" )
    }
    @

    Projects create static library and application without debugging info. But application is dynamically linked and depends from mingwm10.dll, msvcrt.dll, QtCore4.dll, QtGui4.dll. What is wrong and how can I assemble static application without dependence from Qt libraries?



  • is it possible that you use a different Qt version for building? especially, if it relates on msvcrt.dll... This is MSVS build.



  • I found there was setting from older installation. When I removed it I've got error message about throw used but exceptions was prohibited. Now I remembered - I need exceptions allowed for this project. Have to rebuild Qt4 from source again...

    I'd recommend add something in the article. If exceptions are strongly needed, than -no-exceptions options must not be used. But mingw32.dll will be mandatory distributed with application. Not so heavy task. This library is very small.



  • If you use exceptions, there were some minor things with mingw static libs do not work I think. could be this mingw32.dll or whatever the name was.



  • With Qt4.5 it worked well. Hope with 4.7 will work too.



  • In general it works. I used it for some apps, and they need no other dll, but I didn't use exceptions. The thing with the dll is from mingw version, not from qt version :-)



  • SOLVED. After Qt was rebuild with exceptions and properly tuned - program works but requires small 12 KB mingwm10.dll to support exceptions. Not a problem.


Log in to reply
 

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