Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to statically link a Qt application on windows?
QtWS25 Last Chance

How to statically link a Qt application on windows?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.6k 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.
  • X Offline
    X Offline
    xalam
    wrote on last edited by
    #1

    I need to send out my application for testing and of course it requires Qt5Widget.dll plus others. I can't figure out how to simply link the executable to static libraries?

    I am following http://doc.qt.io/qt-5/windows-deployment.html but I am find the documentation lacking.

    it says:

    bq. cd C:\path\to\Qt
    configure -static <any other options you need>

    But c:\Qt is a root folder (default in my case) and configure command is not recognized. I went to c:\Qt\5.3 and still the same case. Also what am I suppose to fill for < <any other options you need> if anything? (I am not not filling it and hope it doesn't mess up)

    First why do we have to go command line just to link statically? I also saw may I need to add this line to .pro file

    @CONFIG += static@

    But this doesn't do anything as well.

    How do I link statically?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ckakman
      wrote on last edited by
      #2

      Hi,

      Do you want to link to Qt statically? If so, you need to build a static version of Qt.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xalam
        wrote on last edited by
        #3

        Is that what need to do? I am coming from VS2010 world and it was a simple settings in my project to link dynamic or statically. But yes I want to link libraries statically (most easy way to distribute exe without sending the dlls). How do I build static version of Qt?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ckakman
          wrote on last edited by
          #4

          "Statically linking a Qt application" does not mean "linking to statically built Qt". You wanted to ask about the latter, but your wording meant the former.

          If you have a library built both as a dynamic and static library than the only thing you have to do is to change the LIBS += line in your pro file so that you link with the library of your choice. That's that easy with qmake. This is called linking to a static or dynamic library.

          But this is not what you are asking. You want to link to a statically built Qt. The thing is that the Qt SDK you have downloaded from qt-project.org does not contain statically built Qt libraries. You have to do that yourself. Make sure that your application is properly licensed if you want your application to link to statically built Qt.

          Building Qt on Windows is explained "here":http://doc.qt.io/qt-5/windows-support.html#building-qt-5-from-source.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xalam
            wrote on last edited by
            #5

            No I am asking the former, I only want to link to static library so the LIBS + line should do but what libs do I include in pro file? My application is already running fine so assume it knows which library to link against, how do I change that from dynamic to static link? Thanks.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ckakman
              wrote on last edited by
              #6

              Which static library? Qt? If yes, you have to build it yourself. It is not available in the Qt SDK. I have already provided the link for building Qt on Windows.

              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