(SOLVED) custom widget collection, LNK2019, LNK1120 problem.



  • Hello.

    I made a custom widget collection with the Qt Custom Designer Widget Project.
    (windows7, Qt5.4.1 MSVC 2010 32bit, Qt Creator3.3.1)

    I can see custom widgets in Qt creator designer and drag it on the mainwindow.ui.

    Now, I have a dll, a lib and three .h files for custom button, checkbox, combobox at 'lib' folder.

    (folder structure)
    untitied2 |- lib -|- snmscontrolfactoryplugin.dll
    untitied2 |- lib -|- snmscontrolfactoryplugin.lib
    untitied2 |- lib -|- snmsqcheckbox.h
    untitied2 |- lib -|- snmsqcombobox.h
    untitied2 |- lib -|- snmsqpushbutton.h
    untitied2 |- main.cpp
    untitied2 |- mainwindow.cpp
    untitied2 |- mainwindow.h
    untitied2 |- mainwindow.ui
    untitied2 |- unittiled2.pro

    (.pro)
    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = untitled2
    TEMPLATE = app

    INCLUDEPATH += $$PWD/lib/
    LIBS += -L$$PWD/lib -lsnmscontrolfactoryplugin

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h
    FORMS += mainwindow.ui

    then, I got this message

    mainwindow.obj : error LNK2019: "public: __thiscall SNMSQComboBox::SNMSQComboBox(class QWidget *)" (??0SNMSQComboBox@@QAE@PAVQWidget@@@Z) 외부 기호(참조 위치: "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 함수)에서 확인하지 못했습니다.
    mainwindow.obj : error LNK2019: "public: __thiscall SNMSQCheckBox::SNMSQCheckBox(class QWidget *)" (??0SNMSQCheckBox@@QAE@PAVQWidget@@@Z) 외부 기호(참조 위치: "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 함수)에서 확인하지 못했습니다.
    mainwindow.obj : error LNK2019: "public: __thiscall SNMSQPushButton::SNMSQPushButton(class QWidget *)" (??0SNMSQPushButton@@QAE@PAVQWidget@@@Z) 외부 기호(참조 위치: "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 함수)에서 확인하지 못했습니다.
    release\untitled2.exe : fatal error LNK1120: 3개의 확인할 수 없는 외부 참조입니다.

    how can I resolve it?

    (SOLVED)
    I found a solution.
    The Qt Custom Designer Widget Project doesn't make the dll macro in the header file.
    So, need to include dll export macro in each header file like this.

    #include <QtDesigner/QtDesigner>
    #include <QPushButton>
    class QDESIGNER_WIDGET_EXPORT SNMSQPushButton : public QPushButton
    {
    ~~
    ~~
    ~~
    }


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Is snmscontrolfactoryplugin built with MSVC2010 32bit ?



  • Hi~ SGaist.
    Yes, I built with MSVC2010 32bit.


  • Lifetime Qt Champion

    You should use your own version of that macro. You might very well build your project against a Qt where designer wasn't built.


Log in to reply
 

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