PDA

View Full Version : Create a DLL with a static build of Qt 4.3



ucomesdag
5th May 2008, 13:43
All compilles and runs fine. But when compilling with a static version of Qt the program exits when calling the dll.

Modified the .pro file:
CONFIG += staticlib static qt thread

But this doesn't ouput a dll. I know that "dll" produces a shared library.
What I want is an executable with no dependencies except from the .dll.

stevey
6th May 2008, 00:29
If you want to output a dll then you'll need to use 'dll' instead of 'staticlib'. staticlib will output a .lib file instead of a dll that can be statically linked into another exe / dll.



All compilles and runs fine. But when compilling with a static version of Qt the program exits when calling the dll.

How are you building your main exe, can you show us the .pro file?

ucomesdag
6th May 2008, 07:11
lib.pro

TEMPLATE = lib
#VERSION = 0.1.0
CONFIG += staticlib static dll qt thread

CONFIG += debug_and_release
CONFIG(debug, debug|release) {
TARGET = "testdll"
DESTDIR = ../../debug
OBJECTS_DIR += ../../debug/tmp
MOC_DIR += ../../debug/tmp
UI_DIR += ../../debug/tmp
}
else {
TARGET = "testdll"
DESTDIR = ../../release
OBJECTS_DIR += ../../release/tmp
MOC_DIR += ../../release/tmp
UI_DIR += ../../release/tmp
}

# DEFINES only needed for windows
win32 {
CONFIG(dll) {
DEFINES += BUILD_DLL
}
}

# Input
HEADERS += qtestdll.h
SOURCES += qtestdll.cpp
app.pro
TEMPLATE = app
CONFIG += static

CONFIG += debug_and_release
CONFIG(debug, debug|release) {
TARGET = "test"
DESTDIR = ../../debug
OBJECTS_DIR += ../../debug/tmp
MOC_DIR += ../../debug/tmp
UI_DIR += ../../debug/tmp
}
else {
TARGET = "test"
DESTDIR = ../../release
OBJECTS_DIR += ../../release/tmp
MOC_DIR += ../../release/tmp
UI_DIR += ../../release/tmp
}

QT += core gui

SOURCES += main.cpp
RESOURCES +=

ucomesdag
6th May 2008, 13:29
For those interested in the code:

ucomesdag
7th May 2008, 14:12
All applications created with a static library will be at least 1.5MB in size and it is not possible to build or use any components or plugins with a static Qt library.



http://trolltech.com/developer/knowledgebase/21/

Guess that answers my question except if there is an other way ;)