Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Create DLL problem

Create DLL problem

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 2.5k 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.
  • G Offline
    G Offline
    Garthfield
    wrote on last edited by
    #1

    I'm trying to create a windows DLL. I think my custom compilation of QT may be the problem. I compiled QT from scratch as static (added -static compile option), is this the reason why I can't build DLLs?

    I followed this YT tutorial to the letter (http://www.youtube.com/watch?v=ZewJ4iHQvXY)

    I created a simple project called MyLib (Other Project -> C++ Library) with a single test function:

    MyLib.pro
    @QT -= gui

    TARGET = MyLib
    TEMPLATE = lib

    DEFINES += MYLIB_LIBRARY

    SOURCES += mylib.cpp

    HEADERS += mylib.h
    MyLib_global.h@

    mylib.h
    @#ifndef MYLIB_H
    #define MYLIB_H

    #include "MyLib_global.h"
    #include <QDebug>

    class MYLIBSHARED_EXPORT MyLib {
    public:
    MyLib();
    void Test();
    };

    #endif // MYLIB_H@

    MyLib_global.h
    @#ifndef MYLIB_GLOBAL_H
    #define MYLIB_GLOBAL_H

    #include <QtCore/qglobal.h>

    #if defined(MYLIB_LIBRARY)

    define MYLIBSHARED_EXPORT Q_DECL_EXPORT

    #else

    define MYLIBSHARED_EXPORT Q_DECL_IMPORT

    #endif

    #endif // MYLIB_GLOBAL_H@

    mylib.cpp
    @#include "mylib.h"

    MyLib::MyLib() {
    }

    void MyLib::Test() {
    qDebug() << "From DLL";
    }@

    When I build the project only the .a and .o files are created, there's no DLL file being created.

    Here's the compile output:
    @c:\development\qt\qmake\qmake.exe -spec ........\development\Qt\mkspecs\win32-g++ CONFIG+=declarative_debug -o Makefile MyLib.pro
    C:/development/Qt/qtcreator-2.4.1/mingw/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory C:/Users/u100404/Projects/MyLib' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DMYLIB_LIBRARY -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\development\Qt\include\QtCore" -I"..\..\..\..\development\Qt\include" -I"..\..\..\..\development\Qt\include\ActiveQt" -I"debug" -I"..\..\..\..\development\Qt\mkspecs\win32-g++" -o debug\mylib.o mylib.cpp ar -ru debug\libMyLib.a debug/mylib.o mingw32-make.exe[1]: Leaving directory C:/Users/u100404/Projects/MyLib'@

    Also after compilation QT pops up a dialog box saying there's no executable found and it's prompting me to search for one. But of course there's no executable I'm building a DLL library file!

    !http://www.cssmixes.co.uk/images/qt-error.jpg(Could not find executable error)!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Looks strange ;-)

      You get a static library libMyLib.a instead of shared library.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Garthfield
        wrote on last edited by
        #3

        [quote author="1+1=2" date="1339207183"]Looks strange ;-)

        You get a static library libMyLib.a instead of shared library.[/quote]

        Correct.

        Is this because I compiled QT itself as static? it's therefore not capable of producing shared libraries?

        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