Problem about creating DLL in QtCreator



  • I am creating a DLL in QtCreator, but encounter a link error:
    @
    testqtdll2.obj:-1: error:LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::~QString(void)" (_imp??1QString@@QAE@XZ),the symbol is referenced in "int __cdecl Add(int,int)" (?Add@@YAHHH@Z)
    testqtdll2.obj:-1: error:LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __cdecl QObject::tr(char const *,char const *)" (_imp?tr@QObject@@SA?AVQString@@PBD0@Z),the symbol is referenced in "int __cdecl Add(int,int)" (?Add@@YAHHH@Z)
    @

    Test Code:

    @
    #include <QObject>
    #include <QString>

    #include "testqtdll2.h"

    int TESTQTDLL2SHARED_EXPORT Add(int a, int b)
    {
    QString s = QObject::tr("Just a test");
    return a + b;
    }
    @

    Qt project file:

    @
    QT -= gui
    QT += core
    CONFIG += dll
    TARGET = TestQtDLL2
    TEMPLATE = lib
    DEFINES += TESTQTDLL2_LIBRARY
    SOURCES += testqtdll2.cpp
    HEADERS += testqtdll2.h
    TestQtDLL2_global.h
    symbian {
    MMP_RULES += EXPORTUNFROZEN
    TARGET.UID3 = 0xE746BF96
    TARGET.CAPABILITY =
    TARGET.EPOCALLOWDLLDATA = 1
    addFiles.sources = TestQtDLL2.dll
    addFiles.path = !:/sys/bin
    DEPLOYMENT += addFiles
    }
    unix:!symbian {
    maemo5 {
    target.path = /opt/usr/lib
    } else {
    target.path = /usr/lib
    }
    INSTALLS += target
    }
    @

    Thanks in advance

    [EDIT: code formatting: please wrap in @-tags, Volker]



  • Could anynone give me a help?


Log in to reply
 

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