1
votes

I would like to create a Dll on Windows using QMake+mingw, which includes some custom widgets and the dependent Qt libraries (linked into one library). Can this be achieved via QMake?

What I have tried so far:

Creating shared library project, and adding LIBS to .pro file:

QT       += widgets
TARGET = testqtdll
TEMPLATE = lib
DEFINES += TESTQTDLL_LIBRARY
SOURCES += testqtdll.cpp widget.cpp
HEADERS += testqtdll.h testqtdll_global.h widget.h
FORMS += widget.ui
LIBS += -lqt5core -lqt5gui -lqt5widgets

This way the resulting dll does not include QT libs.

Creating static library project, and link qt static libs. Then create dll after:

QT       += widgets    
TARGET = testqtlib
TEMPLATE = lib
CONFIG += staticlib    
SOURCES += testqtlib.cpp widget.cpp
HEADERS += testqtlib.h widget.h
FORMS += widget.ui
LIBS += c:/Qt/Static/5.3.1/lib/Qt5Core.a
LIBS += c:/Qt/Static/5.3.1/lib/Qt5Gui.a 
LIBS += c:/Qt/Static/5.3.1/lib/Qt5Widgets.a

This way the resulting lib also does not include QT libs.

1
on your shared library project case, you should also link static libraries like you did below.UmNyobe
Not working, they are not added to the linker callsimon
can you post dependency walker snapshot of the testqtdll? We need to see the effective linkage of the resulting libraryUmNyobe

1 Answers

1
votes

I found a solution after all. One should use the Qt static build to create such dll. Working project file:

QT       += core gui widgets
CONFIG += static dll
TARGET = testqtdll
TEMPLATE = lib
DEFINES += TESTQTDLL_LIBRARY
SOURCES += testqtdll.cpp widget.cpp
HEADERS += testqtdll.h testqtdll_global.h widget.h
FORMS += widget.ui