Skip to content

The generated dynamic library cannot be used in my project #38

@wslyw

Description

@wslyw

Hello, my default development environment is Qt 5.15.2 with MSVC 2019 64-bit, and I have built both the .lib and .dll files using qmake. However, I am encountering compilation errors when trying to use them in my project. I have also attempted to modify the .pro file, but it has not resolved the issue.
Here is the .pro file after my modifications.

TEMPLATE = lib

CONFIG += c++17

DEFINES += ADS_NAMESPACE_ENABLED ADS_EXPORT
QT += core

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

INCLUDEPATH += $$PWD/include

RESOURCES += \
	res/ads.qrc

!isEmpty(target.path): INSTALLS += target
include(AdvancedDockingSystem.pri)

And here is the part in my project related to importing the library and header files.

win32: LIBS += -L$$PWD/lib/ -lAdvancedDockingSystem
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include

The error message is:

error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl ContainerWidget::ContainerWidget(class QWidget *)" (__imp_??0ContainerWidget@@QEAA@PEAVQWidget@@@Z),函数 "public: __cdecl TableViewForm::TableViewForm(class QWidget *)" (??0TableViewForm@@QEAA@PEAVQWidget@@@Z) 中引用了该符号
tableviewform.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __cdecl ContainerWidget::~ContainerWidget(void)" (__imp_??1ContainerWidget@@UEAA@XZ),函数 "public: virtual void * __cdecl ContainerWidget::`scalar deleting destructor'(unsigned int)" (??_GContainerWidget@@UEAAPEAXI@Z) 中引用了该符号
tableviewform.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class SectionWidget * __cdecl ContainerWidget::addSectionContent(class QSharedPointer<class SectionContent> const &,class SectionWidget *,enum DropArea)" (__imp_?addSectionContent@ContainerWidget@@QEAAPEAVSectionWidget@@AEBV?$QSharedPointer@VSectionContent@@@@PEAV2@W4DropArea@@@Z),函数 "public: __cdecl TableViewForm::TableViewForm(class QWidget *)" (??0TableViewForm@@QEAA@PEAVQWidget@@@Z) 中引用了该符号
tableviewform.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __cdecl ContainerWidget::metaObject(void)const " (?metaObject@ContainerWidget@@UEBAPEBUQMetaObject@@XZ)
tableviewform.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __cdecl ContainerWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@ContainerWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
tableviewform.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __cdecl ContainerWidget::qt_metacast(char const *)" (?qt_metacast@ContainerWidget@@UEAAPEAXPEBD@Z)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions