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 Qt on Windows w Visual Studio 2017
Qt 6.11 is out! See what's new in the release blog

How to statically link Qt on Windows w Visual Studio 2017

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 3.1k 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.
  • M Offline
    M Offline
    mjsmithers
    wrote on last edited by mjsmithers
    #1

    Hi,

    I've just purchased the QT commercial license and my (maybe naive) understanding was that when Qt installed under this license, static linking would be as simple as adding "CONFIG += static" into the project .PRO file, however this doesn't work. (The build defaults to dynamic linking, which does work but requires running windeployqt.exe.) "QMAKE_LFLAGS = -MT" doesn't help with static linking either.

    Can anyone - preferably commercial license holders - point me in the right direction? I'm using Visual Studio 2017 with the QT plugin, and Qt versions 5.9.5 and newer.

    Many pages talk about first rebuilding Qt with static options. E.g.
    https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows

    They refer to running "configure" however my PC (which includes MSVC2017 and QT) only has some "configure.prf" files in some QT mkspecs\features directories. There aren't any configure.exe or configure.bat files.

    http://doc.qt.io/qt-5/windows-deployment.html#linking-the-application-to-the-static-version-of-qt
    doesn't help either.

    Many thanks,
    M

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mjsmithers
      wrote on last edited by
      #2

      Ok, after running the Qt maintenance tool again and downloading the Src directory for Qt 5.9.5, I found the "configure.bat" file in c:\Qt\5.9.5\Src.

      I then started the Visual Studio 2017 Command Prompt, changed to the c:\Qt\5.9.5\Src directory and ran
      configure -static -release -platform win32-msvc
      The bat file prompted me for a few extra things, such as licensing.

      When the script finished, I ran
      nmake
      only to have the build fail at ioutils.cpp with a path problem.

      Turns out c:\Qt\5.9.5\Src\bin\qt.conf had unix paths, instead of Windows paths, so I changed the three Prefix lines to C:\Qt\5.9.5 and restarted nmake.

      So far the build is working.

      Best,
      M

      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