[SOLVED] Force Qt5 Creator to generate a dll instead of lib
-
I'm running Win7x64 with Qt 5.3.1 32-bit (VS2012, OpenGL) and VS 2012 Express installed.
(Note: I would have preferred to use the 64-bit version of Qt but unfortunately that needs VS 2013 Express which apparently requires Win8)So in Creator, I open an existing Widgets .project,
include (../../Flags.pri )
OBJECTS_DIR = ../objects
TARGET = analogwidgets
DESTDIR = ../
CONFIG += release
warn_on
staticlib
TEMPLATE = liband verify the Qt 5.3 MSVC OpenGL is detected, as well the compiler is detected (MSVC 11 (x86, amd64))
However after building, a 2.8MB .lib file is generated instead of a .dll.
I don't really have a preference if my windows desktop application will link statically or dynamically to the widgets code, however the plugin folder in Qt Designer all have .dlls.. so placing my .lib file in there doesn't seem to work (i.e. Qt Designer doesn't see the Widgets plugin created).
How can I force Qt Creator to generate a dll OR how can I get Qt Designer to show the widgets from a lib file?
******* UPDATE ********
Few things got it to work:- there were 3 .pro files, and I hadn't opened the correct 'plugins' one.
All the cpp files had the lines:
#ifndef SINGLEPLUGINS
Q_EXPORT_PLUGIN(AnalogWidgetsPlugin)
#endifIn order to overcome a "Old plugin system used" error, I had to comment out these lines on the (first?) cpp file that had it.
Once the dll was created and placed in the folder:
C:\Qt\Qt5.3.1\5.3\msvc2012_opengl\plugins\designerDesigner complained of the dll : "Plugin verification data mismatch"
So in the header file that defined the widget class (inherited from QObject & QDesignerCustomWidgetCollectionInterface), after the Q_OBJECT line I added:
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin")Now after re-generating the dll and placing in the plugins folder it worked!
Thanks!
-
About 64-bits Qt and the problem that VS2013 Express requires Windows 8.1 or later: the usual trick (which I did :-) is to go to visualstudio.com and select a trial version of VS2013, in this case Windows 7 SP1 is kosher. Default download is VS2013 Ultimate but you can get the Professional version if you click on 'Additional Visual Studio downloads and tools". The trial version will expire after 3 months, however Qt will function the same regardless if the trial has expired or not.
About the custom widget, you definitely need a .dll for Qt Designer to be happy, are you sure none is generated? A .lib file is always generated as part of the build process. Your .pro file seems a bit lacking, I think it needs the line:
@
QT += designer
@ -
Thanks, added the line, but no .dll anywhere in site..
This is the complete .pro file, there is a line at the bottom about a static lib path, but removing it didn't seem to make a dll instead of .lib
RESOURCES += analogwidgets.qrc
HEADERS += ../analogwidgets/chart/chartdecorator.h
item.hSOURCES += chart/scalegrid.cpp
potentiometer.cppINCLUDEPATH += .. \
../analogwidgetsinclude (../../Flags.pri )
OBJECTS_DIR = ../objects
TARGET = analogwidgets
DESTDIR = ../
CONFIG += release
warn_on
staticlib
TEMPLATE = lib
QT += designerheaders.files += ../analogwidgets/.h
headers_chart.files += ../analogwidgets/chart/.h
headers_standard.files += ../analogwidgets/chart/standard/*.h
headers.path += $$INSTALL_INCLUDEDIR/analogwidgets
headers_chart.path += $$INSTALL_INCLUDEDIR/analogwidgets/chart
headers_standard.path += $$INSTALL_INCLUDEDIR/analogwidgets/chart/standardstaticlib.files += ../libanalogwidgets.a
staticlib.path += $$INSTALL_LIBDIR/INSTALLS += headers headers_chart headers_standard staticlib
WIN32{
DEFINES+= WIN32
}