Home > Enterprise >  In Qt and cmake, how can I moc files generate with my API( dll export) macro
In Qt and cmake, how can I moc files generate with my API( dll export) macro

Time:08-21

In my case, I have a macro for dll export like this:(very very brief version of the declaration)

#ifdef EXPORTDLL 
#define MMAPI _declspec(export)
...

And my class like this:

Class MMAPI myClass: public qobject{
Q_Object()
...

Generally, mmapi is assigned as export.

And I take a linker error because of (in my opinion) staticmetaobject which created by auto moc and cmake for not declered as export dll. I found out some solutions for this. That solutions advice that, include some macro line to cmake file for generate export file. Unfortunately, I don't want to do that. I want use my mmapi.

On short, how can I generate staticmetaobject with my macro.

From now, thank you all for your helps.

Edit: when I change library type to static project build but qrc file not found by qml and qt libs

CodePudding user response:

I find out what is the problem. When I define exportdll macro separately and private for each library in cmake, problem solved. My main app lib somehow see the macro.

  • Related