Results 1 to 2 of 2

Thread: Qt Standalone Application Static Linking?

  1. #1
    Join Date
    Jan 2012
    Posts
    12
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt Standalone Application Static Linking?

    Hello,

    I am trying to get Qt to statically link libraries so that I can make a standalone application. I have followed various tutorials on how to build Qt statically then building a static application but I am not having much luck. I believe I have succesfully built Qt with static linking because the application has grown in size from 79KB to 7+MB but I am still getting errors saying QtCore4.dll and QtSerialPort.dll are missing. Also, another issue I'm having when using this static configuration, which isn't too serious, is that when I close my program Windows thinks it has crashed and gives me a window saying MyProgram.exe has stopped working...

    I am on a Windows machine using MSVC 2010 with Qt 4.8.5 and am using the third party library QtSerialPort.

    What I've done accoring to the guides I've been reading is:

    Download and extract qt-everywhere-opensource-src-4.8.5.zip Open /mkspec/mwin32-msvc2010/qmake.conf and change the follwing lines to

    CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target

    and

    QMAKE_CLFAGS_RELEASE = -O2 -MT

    I then open the MSVC2010 command prompt and cd to this . I then enter the commands

    configure -static -release -platform win32-msvc2010
    nmake sub-src

    After this is done I open my project and add

    CONFIG += static

    to the .pro file. In QtCreator I then go into Projects, Manage Kits then to Qt Versions and browse to the qMake I just generated. I add a new Kit with this version of qMake. I then clean all and switch to this new kit and run qmake from QtCreator. I then use msvc2010 command prompt to go to the directory where the files are generated and then

    nmake release

    This generates a rather large .exe but like I said, it's still depending on a couple .dll's.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Standalone Application Static Linking?

    You need to build a static version of QtSerialPort also (if possible) because your program is currently linked to the dynamic library and it is linked to the dynamic Qt4.

Similar Threads

  1. Qt application is not compiling with static linking?
    By gurmeetsingh in forum Qt Programming
    Replies: 14
    Last Post: 24th April 2012, 06:21
  2. Replies: 3
    Last Post: 7th February 2012, 10:40
  3. Replies: 3
    Last Post: 1st June 2011, 15:32
  4. Static Linking Application for Realease
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2007, 18:12
  5. Replies: 2
    Last Post: 1st August 2007, 15:04

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.