Results 1 to 13 of 13

Thread: Link all Qt libs statically.

  1. #1
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Link all Qt libs statically.

    Hi

    I'm about to start working on a new project. One Of the requirements is to build an application consisting of a single executable file, which would run without any installation/setup/etc. Pretty much how things work on Macs.

    Is it possible to link Qt libs statically? How do I do this under windows?

    Thanks
    Anton

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Link all Qt libs statically.


  3. #3
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    7
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Link all Qt libs statically.

    Yes, it's possible

    If you are using MinGW:
    ./configure -prefix /Developer/Qt/4.4.3 -platform win32-g++ -qt-zlib -qt-libpng -qt-libjpeg -static -release
    Kind regards,
    Xesc.

  4. #4
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Link all Qt libs statically.

    oops, what a shame
    I should have RTFM before asking

    Thanks

  5. #5
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Link all Qt libs statically.

    err.. Looks like it's not as easy as I tought. Qt libs are linked statically and there is not problem.

    What I want to do not - is to link to Qt libs to Visual Studio CRT library statically. And then link to Qt libs, so there are no external dependencies. Is it possible? How do I do this?

    Thanks
    Anton

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Link all Qt libs statically.

    In menu :

    Project/Properties/Configuration Properties/C/C++/Code Generation

    see the "Runtime Library" choices. The choices that do not contain "DLL" are the static linking options.

  7. #7
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Link all Qt libs statically.

    Quote Originally Posted by Lesiok View Post
    In menu :

    Project/Properties/Configuration Properties/C/C++/Code Generation

    see the "Runtime Library" choices. The choices that do not contain "DLL" are the static linking options.
    i's not really a solution. Qt libs are linked against dynamic runtime by default. So if we change the project settings as you suggest the application will be linked against a different runtime, which obviously wont link properly.

    So I'm looking for a way to compile static Qt libs statically with CRT linked statically.

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Link all Qt libs statically.

    See our wiki: [WIKI]Building static applications[/WIKI]
    J-P Nurmi

  9. #9
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Link all Qt libs statically.

    Quote Originally Posted by jpn View Post
    See our wiki: [WIKI]Building static applications[/WIKI]
    Thanks, but this is not what I'm looking for.

    CRT still wont be compiled into Qt binaries. The resulting Exe's and Dll's will be dependent on CRT Dll's

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Link all Qt libs statically.

    Quote Originally Posted by psih128 View Post
    Thanks, but this is not what I'm looking for.

    CRT still wont be compiled into Qt binaries. The resulting Exe's and Dll's will be dependent on CRT Dll's
    It's all there, just read through the article. Pay attention to "Building static Qt on Windows".
    J-P Nurmi

  11. #11
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Link all Qt libs statically.

    Quote Originally Posted by jpn View Post
    It's all there, just read through the article. Pay attention to "Building static Qt on Windows".
    I read the article properly.
    If you perform all the steps described in the article you will end up with a large exe containing all Qt modules, but depending on CRT. For example building using Visual Studio 2005 will add a dependency to MSVCR80.dll. Most of the systems have VC++ 2005 Redist installed, but some dont. On those few systems the application wont run.

  12. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Link all Qt libs statically.

    Quote Originally Posted by psih128 View Post
    I read the article properly.
    If you perform all the steps described in the article you will end up with a large exe containing all Qt modules, but depending on CRT. For example building using Visual Studio 2005 will add a dependency to MSVCR80.dll. Most of the systems have VC++ 2005 Redist installed, but some dont. On those few systems the application wont run.
    Did you read the step about editing mkspecs: [WIKI]Building static Qt on Windows with MSVC[/WIKI]?
    J-P Nurmi

  13. The following user says thank you to jpn for this useful post:

    psih128 (30th December 2008)

  14. #13
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Link all Qt libs statically.

    Quote Originally Posted by jpn View Post
    Did you read the step about editing mkspecs: [WIKI]Building static Qt on Windows with MSVC[/WIKI]?
    This seems to be exactly what I need!
    Thanks a lot - finally this is resolved

Similar Threads

  1. Statically Linking... everything
    By bpetty in forum Newbie
    Replies: 5
    Last Post: 26th October 2006, 17:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.