Search code examples
c++qtqmake

How can i create a Single exe of QT Console Application , with static libraries,


I have created a Qt Console application , but when i tried a release exe , its showing lots of library missing errors,how can i solve this , i need a standalone exe . All the libraries should be within the exe . pls help me ..

My Current QT Pro file is this

#-------------------------------------------------
#
# Project created by QtCreator 2012-03-15T15:50:07
#
#-------------------------------------------------


QT       += core network xml
QT       -= gui

TARGET = BillingClient
CONFIG   += console
CONFIG   -= app_bundle
CONFIG   += debug_and_release
TEMPLATE = app


SOURCES += main.cpp

HEADERS += \
    HttpDaemon.h \
    Config.h \
    Logger.h \
    XmlReader.h \
    RequestHandler.h

OTHER_FILES += \
    System.ini \
    Response.xml

Libraries Missing are ..

libgcc_s_dw2-1.dll mingwm10.dll

etc..


Solution

  • libgcc_s_dw2-1.dll mingwm10.dll
    

    Those libraries are dependencies of programs built by MinGW compiler. To get rid of those dll's and if I remember correctly use LIBS += -static. If you want to link Qt libraries statically, than you should build qt libraries statically

    UPDATE


    If you want to get rid of those 2 dll's I mentioned above, put LIBS += -static in your .pro file.

    If you want to get rid of dlls such as QtCore4.dll QtGui4.dll etc, you should rebuild Qt source code statically. If you go this way, you should first choose which compiler you want to use. Currently I'm using MSVC 2010. Just download latest qt sources, execute configure.exe with the following parameters: -debug-and-release -platform win32-msvc2010 -sse -sse2 -no-qt3support -no-s60 -no-cetest -saveconfig config -mp and follow instructions (Keep in mind that you should have MSVC compiler installed. Just download MSVC 2010 express, it's free). Compilation will take several hours. When it's done, you should register your newly compiled Qt libraries in QtCreator. To do this, launch QtCreator -> Tools -> Options -> Build & run -> Qt Versions -> Add. When new dialog pops up, navigate to the folder where your qt source code resides, go to bin and select qmake.exe. Enter the name of qt version, for example: "Qt Static" and that's it. After that you will be able to choose your new qt libraries from project settings.

    Hope it helps, if there's something not clear for you, feel free to ask.