Unable to link Qt dll
Unsolved
General and Desktop
-
Hi everybody,
I've created a simple shared library, containing just one class that does nothing, and it builds correctly.
Now I 'd like to use this library in a Qt application: so right click on the project name, "Add Libraray" and I've specified the path to the .lib file of my dll.
Try build the application, but still getting linker error: LNK1104 cannot open file "myLibrary.lib"I'm using Qt5.9 on Windows 64bits, both to build the shared library and the application, with msvc 2013.
Thanks
Andrea -
Hi @jsulm
here the .pro file of the application
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = dllTest TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../Prova/testLibrary/release/ -ltestLibrary else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../Prova/testLibrary/debug/ -ltestLibrary INCLUDEPATH += $$PWD/../Prova/testLibrary/release DEPENDPATH += $$PWD/../Prova/testLibrary/release```
And here the linker output
Error 38 error LNK1120: 12 unresolved externals C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\Release\ClassProva.dll ClassProva Error 32 error LNK2019: unresolved external symbol "public: __thiscall QString::~QString(void)" (??1QString@@$$FQAE@XZ) referenced in function "public: void * __thiscall QString::`scalar deleting destructor'(unsigned int)" (??_GQString@@$$FQAEPAXI@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 34 error LNK2019: unresolved external symbol "public: __thiscall QString::QString(class QString const &)" (??0QString@@$$FQAE@ABV0@@Z) referenced in function "private: void __thiscall QList<class QString>::node_copy(struct QList<class QString>::Node *,struct QList<class QString>::Node *,struct QList<class QString>::Node *)" (?node_copy@?$QList@VQString@@@@$$FAAEXPAUNode@1@00@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 33 error LNK2019: unresolved external symbol "public: static void __cdecl QListData::dispose(struct QListData::Data *)" (?dispose@QListData@@$$FSAXPAUData@1@@Z) referenced in function "private: void __thiscall QList<class QString>::dealloc(struct QListData::Data *)" (?dealloc@?$QList@VQString@@@@$$FAAEXPAUData@QListData@@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 35 error LNK2019: unresolved external symbol "public: struct QListData::Data * __thiscall QListData::detach(int)" (?detach@QListData@@$$FQAEPAUData@1@H@Z) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 36 error LNK2019: unresolved external symbol "public: void * * __thiscall QListData::begin(void)const " (?begin@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 37 error LNK2019: unresolved external symbol "public: void * * __thiscall QListData::end(void)const " (?end@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 26 error LNK2028: unresolved token (0A000200) "public: __thiscall QString::QString(class QString const &)" (??0QString@@$$FQAE@ABV0@@Z) referenced in function "private: void __thiscall QList<class QString>::node_copy(struct QList<class QString>::Node *,struct QList<class QString>::Node *,struct QList<class QString>::Node *)" (?node_copy@?$QList@VQString@@@@$$FAAEXPAUNode@1@00@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 27 error LNK2028: unresolved token (0A000207) "public: __thiscall QString::~QString(void)" (??1QString@@$$FQAE@XZ) referenced in function "public: void * __thiscall QString::`scalar deleting destructor'(unsigned int)" (??_GQString@@$$FQAEPAXI@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 28 error LNK2028: unresolved token (0A000241) "public: void * * __thiscall QListData::begin(void)const " (?begin@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 29 error LNK2028: unresolved token (0A000242) "public: void * * __thiscall QListData::end(void)const " (?end@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 30 error LNK2028: unresolved token (0A000535) "public: struct QListData::Data * __thiscall QListData::detach(int)" (?detach@QListData@@$$FQAEPAUData@1@H@Z) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva Error 31 error LNK2028: unresolved token (0A00058E) "public: static void __cdecl QListData::dispose(struct QListData::Data *)" (?dispose@QListData@@$$FSAXPAUData@1@@Z) referenced in function "private: void __thiscall QList<class QString>::dealloc(struct QListData::Data *)" (?dealloc@?$QList@VQString@@@@$$FAAEXPAUData@QListData@@@Z) C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\ClassProva\ClassProva.obj ClassProva
-
Oh, yeah, sorry..here it is
1>------ Rebuild All started: Project: ClassProva, Configuration: Release Win32 ------ 1> Stdafx.cpp 1> AssemblyInfo.cpp 1> ClassProva.cpp 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(497): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(498): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(499): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(501): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(503): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(505): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(506): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(508): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(509): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(511): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(512): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(513): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(514): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(515): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(517): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(519): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(521): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(523): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(530): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(531): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(532): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(556): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(557): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(558): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1>C:\Qt\Qt5.9.2\5.9.2\msvc2013_64\include\QtCore/qchar.h(559): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall' 1> Generating Code... 1> .NETFramework,Version=v4.5.AssemblyAttributes.cpp 1>ClassProva.obj : error LNK2028: unresolved token (0A000200) "public: __thiscall QString::QString(class QString const &)" (??0QString@@$$FQAE@ABV0@@Z) referenced in function "private: void __thiscall QList<class QString>::node_copy(struct QList<class QString>::Node *,struct QList<class QString>::Node *,struct QList<class QString>::Node *)" (?node_copy@?$QList@VQString@@@@$$FAAEXPAUNode@1@00@Z) 1>ClassProva.obj : error LNK2028: unresolved token (0A000207) "public: __thiscall QString::~QString(void)" (??1QString@@$$FQAE@XZ) referenced in function "public: void * __thiscall QString::`scalar deleting destructor'(unsigned int)" (??_GQString@@$$FQAEPAXI@Z) 1>ClassProva.obj : error LNK2028: unresolved token (0A000241) "public: void * * __thiscall QListData::begin(void)const " (?begin@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) 1>ClassProva.obj : error LNK2028: unresolved token (0A000242) "public: void * * __thiscall QListData::end(void)const " (?end@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) 1>ClassProva.obj : error LNK2028: unresolved token (0A000535) "public: struct QListData::Data * __thiscall QListData::detach(int)" (?detach@QListData@@$$FQAEPAUData@1@H@Z) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) 1>ClassProva.obj : error LNK2028: unresolved token (0A00058E) "public: static void __cdecl QListData::dispose(struct QListData::Data *)" (?dispose@QListData@@$$FSAXPAUData@1@@Z) referenced in function "private: void __thiscall QList<class QString>::dealloc(struct QListData::Data *)" (?dealloc@?$QList@VQString@@@@$$FAAEXPAUData@QListData@@@Z) 1>ClassProva.obj : error LNK2019: unresolved external symbol "public: __thiscall QString::~QString(void)" (??1QString@@$$FQAE@XZ) referenced in function "public: void * __thiscall QString::`scalar deleting destructor'(unsigned int)" (??_GQString@@$$FQAEPAXI@Z) 1>ClassProva.obj : error LNK2019: unresolved external symbol "public: static void __cdecl QListData::dispose(struct QListData::Data *)" (?dispose@QListData@@$$FSAXPAUData@1@@Z) referenced in function "private: void __thiscall QList<class QString>::dealloc(struct QListData::Data *)" (?dealloc@?$QList@VQString@@@@$$FAAEXPAUData@QListData@@@Z) 1>ClassProva.obj : error LNK2019: unresolved external symbol "public: __thiscall QString::QString(class QString const &)" (??0QString@@$$FQAE@ABV0@@Z) referenced in function "private: void __thiscall QList<class QString>::node_copy(struct QList<class QString>::Node *,struct QList<class QString>::Node *,struct QList<class QString>::Node *)" (?node_copy@?$QList@VQString@@@@$$FAAEXPAUNode@1@00@Z) 1>ClassProva.obj : error LNK2019: unresolved external symbol "public: struct QListData::Data * __thiscall QListData::detach(int)" (?detach@QListData@@$$FQAEPAUData@1@H@Z) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) 1>ClassProva.obj : error LNK2019: unresolved external symbol "public: void * * __thiscall QListData::begin(void)const " (?begin@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) 1>ClassProva.obj : error LNK2019: unresolved external symbol "public: void * * __thiscall QListData::end(void)const " (?end@QListData@@$$FQBEPAPAXXZ) referenced in function "public: __thiscall QList<class QString>::QList<class QString>(class QList<class QString> const &)" (??0?$QList@VQString@@@@$$FQAE@ABV0@@Z) 1>C:\Users\Andrea.Laini\Desktop\Prova\ClassProva\Release\ClassProva.dll : fatal error LNK1120: 12 unresolved externals ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
-
Hi,
Can you show your class definition ?