Create DLL problem



  • 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 directoryC:/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)!



  • Looks strange ;-)

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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.