I want to make two QObject libraries using cmake on windows: ProA & ProB, where ProB depend on ProA.
I want to make two QObject libraries using cmake on windows: ProA & ProB, where ProB depend on ProA.
The code of ProA looks like:
class ProA_Export ProA: public QWidget
{
Q_OBJECT
public:
...
};
The CMake script of ProA looks like:
set(CMAKE_AUTOMOC ON)
The ProB links ProA in CMake: target_link_libraries(ProB ProA)
.
Then, when I #include "ProA.h"
in ProB, it reproted:
unresolved external symbol "public: static struct QMetaObject const ProA::staticMetaObject"
And, I can seee mocs_compilation_Debug.cpp
in the vs, and the content of mocs_compilation_Debug
is #include <EWIEGA46WW/moc_ProA.cpp>
. I also find moc_ProA.cpp
in build\autogen\include_Debug\EWIEGA46WW\moc_ProA.cpp
If I remove the Q_OBJECT
from ProA, everything is OK except that the signal-slot of QT do not work.
So, how can I solve the unresolved external symbol
problem caused by Q_OBJECT
?
Any suggestion is appreciated~~~