cmake automoc + dll... error LNK2001: unresolved external symbol "public: static struct QMetaObject
-
Hey
So I've recently started to "dll" up my project.
So far its been... "fun" but I hit a few walls... mainly with Qt mocs as far as I can tell.I can see that my main library gets mocs generated. But then when I make my test they error up with the error in the topic.
As far as I can tell... I need to somehow include these moc files in dirs for my test apps as well?
I can see them being generated inlibraryA_autogen
and some subfolders... there is alsomocs_compilation.cpp
My question is... if I want to include my dll app that uses qt in another app. (as this is backend framework) How do I Deal with mocs?
Do I have to write some kind of post build command that copies all moc files to some location & ship it with my dll/include folder?
How can I find those moc files when I make them in 1st place ?I have a one - make it all - cmake file that makes lib, then makes test projects & link dlls/libs to each test project.
Im on Windows, qt6+, cmake
Can any1 hint me up what to do here?
As far as I can tell if I include mocs_compilation.cpp in my test cpp, the app compiles properly. so that means I have to "auto include it for all" so that I get those mocs from my framework/dll ?
Any help/hints? I used .lib in past didnt have to do any of it, but dll fails. -
@Dariusz said in cmake automoc + dll... error LNK2001: unresolved external symbol "public: static struct QMetaObject:
Do I have to write some kind of post build command that copies all moc files to some location & ship it with my dll/include folder?
no, the moc data is compiled into your binary, like any other class/method etc.
Since you are using cmake, did you set the AUTOMOC property?!
https://doc.qt.io/qt-6/cmake-get-started.html