Qt Static and 3rd party static library
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.
- 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
- 2) Edit <QTDIR>\qmake\Makefile.win32-g++
- LFLAGS = -static -static-libgcc -s
- 3) 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
- 4) Build it. This is gonna take a while (2-3 hours).
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 ?