Important: Please read the Qt Code of Conduct -

[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
    TEMPLATE = lib

    and 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:

    1. there were 3 .pro files, and I hadn't opened the correct 'plugins' one.

    All the cpp files had the lines:

    In 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:

    Designer 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!


  • 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 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

    SOURCES += chart/scalegrid.cpp

    INCLUDEPATH += .. \

    include (../../Flags.pri )
    OBJECTS_DIR = ../objects
    TARGET = analogwidgets
    DESTDIR = ../
    CONFIG += release
    TEMPLATE = lib
    QT += designer

    headers.files += ../analogwidgets/.h
    headers_chart.files += ../analogwidgets/chart/
    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/standard

    staticlib.files += ../libanalogwidgets.a
    staticlib.path += $$INSTALL_LIBDIR/

    INSTALLS += headers headers_chart headers_standard staticlib


  • remove staticlib from CONFIG and give it a try.

Log in to reply