Reputation: 348
I have a Subdirs project, there are two subprojects. One is a Qt Quick Controls 2 Application, and other is a Qt Quick 2 Extension Plugin.
TestQtQuickPlugin ( Subdirs project )
|----app ( Qt Quick Controls 2 Application )
| |------main.cpp
| ...
|----plugin ( Qt Quick 2 Extension Plugin )
| |----MyItem.h
| |----MyItem.cpp
| ...
MyItem class inherits from QQuickItem, and it has a method int getNum(). In main method, I will invoke this method by MyItem().getNum().
In Ubuntu, it compiles and runs successful. But in Windows, it occurs error:
main.obj : error LNK2019: unresolved external symbol "public: __cdecl MyItem::MyItem(class QQuickItem *)" (??0MyItem@@QEAA@PEAVQQuickItem@@@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl MyItem::~MyItem(void)" (??1MyItem@@UEAA@XZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: int __cdecl MyItem::getNum(void)" (?getNum@MyItem@@QEAAHXZ) referenced in function main
What is wrong with my project?
Upvotes: 0
Views: 145
Reputation: 5207
Windows uses "symbol hiding" when creating dynamically linked libraries.
In order for symbols to be "visible" outside such a library they need to be "exported".
See the documentation here.
This can actually also be enabled on Linux by setting a respective flag for g++.
Upvotes: 1