Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qt Static and 3rd party static library
Forum Updated to NodeBB v4.3 + New Features

Qt Static and 3rd party static library

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 4.8k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Shabla
    wrote on 8 Mar 2012, 21:48 last edited by
    #1

    Hi, up to now I've been building my application in dynamic build and I'm using QSerialDevice, distributing it with all the needed dlls. I'm building with Mingw using QtCreator on Windows XP. Now I would like to build it statically so that I don't need all those dlls anymore (libgcc_s_dw2-1.dll, mingwm10.dll, QtCore4.dll, QtGui4.dll, and my 3rd party library SerialPort.dll).

    After many research I finally got Qt to compile in static, but I didn't set the parameters right with configure so I'm going to rebuild it again. Since it takes a while I'd like to get it right before I try again.

    I used "this":https://qt-project.org/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc and "this":http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler/ as a reference and came up with these steps :

    @1) Edit <QTDIR>\mkspecs\win32-g++\qmake.conf:

    QMAKE_CFLAGS_RELEASE = -Os -momit-leaf-frame-pointer
    
    QMAKE_LFLAGS = -static -static-libgcc -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
    
    DEFINES += QT_STATIC_BUILD
    
    1. Edit <QTDIR>\qmake\Makefile.win32-g++

      LFLAGS = -static -static-libgcc -s

    2. Configure Qt for static linking: go to <QTDIR> and run this command (it should take 5-10 minutes):

    configure -static -debug-and-release -opensource -confirm-license -no-opengl -platform win32-g++ -no-phonon -no-audio-backend -no-webkit -no-rtti -no-sql-sqlite -no-qt3support -no-libtiff -nomake examples -nomake demos -no-exceptions -no-stl -no-scripttools -no-openssl -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique

    1. Build it. This is gonna take a while (2-3 hours).
      mingw32-make.exe@

    My question is as follow: do I need to do something special for my 3rd party library (QSerialDevice) to be added to the exe (no need for the SerialPort.dll) ? Here are the lines related in my Qt Creator .pro (replace debug with release for that version) :
    @INCLUDEPATH += "C:/dev/libs/qserialdevice-2.0/include"
    LIBS += -L"C:/dev/libs/qserialdevice-2.0/src/debug" -lSerialPort@
    and my "C:\dev\libs\qserialdevice-2.0\src\debug" folder contain both a SerialDevice.a and SerialDevice.dll.

    Now when I build my program with Qt dynamic it needs the SerialPort.dll, so what are the steps to do in order to remove this dependency ?

    Thanks !

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 9 Mar 2012, 06:42 last edited by
      #2

      Two ways:

      1. You can build a statically QSerialDevice, edit src.pro
        @
        #CONFIG += dll
        CONFIG += staticlib
        @

      2. You can directly use the class library, connecting them to your project through the *.pri,
        see /tests/guiapp/guiapp.pro

      The easiest - way to #2.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Shabla
        wrote on 9 Mar 2012, 21:20 last edited by
        #3

        Tried the 2nd way and it works perfectly, thank you !
        I also built Qt static with the above steps and everything works fine !

        1 Reply Last reply
        0

        1/3

        8 Mar 2012, 21:48

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved