Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Force Qt5 Creator to generate a dll instead of lib
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Force Qt5 Creator to generate a dll instead of lib

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snoop911
    wrote on last edited by
    #1

    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 = 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:
    #ifndef SINGLEPLUGINS
    Q_EXPORT_PLUGIN(AnalogWidgetsPlugin)
    #endif

    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:
    C:\Qt\Qt5.3.1\5.3\msvc2012_opengl\plugins\designer

    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!

    Thanks!

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      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
      @

      1 Reply Last reply
      0
      • S Offline
        S Offline
        snoop911
        wrote on last edited by
        #3

        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.h

        SOURCES += chart/scalegrid.cpp
        potentiometer.cpp

        INCLUDEPATH += .. \
        ../analogwidgets

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

        headers.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/standard

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

        INSTALLS += headers headers_chart headers_standard staticlib

        WIN32{
        DEFINES+= WIN32
        }

        1 Reply Last reply
        0
        • N Offline
          N Offline
          NetZwerg
          wrote on last edited by
          #4

          remove staticlib from CONFIG and give it a try.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved