Export all symbols from dlls on windows (including Qt metaobjects)
-
Hey, I am using Qt 6.5 and cmake and I am looking for a way to export all symbols from my dlls, without needing to manually add macros to them. I am aware that there is
WINDOWS_EXPORT_ALL_SYMBOLSfor cmake, but this doesn't seem to export metaobjects, thus giving me errors that tell me that linking those failed.
Is there a solution to this that also links the Qt metaobjects?Thanks in advance.
-
@Christian-Ehrlicher I am pretty sure that there is a limitation of
WINDOWS_EXPORT_ALL_SYMBOLS, namely that it can not export static symbols. Do you know some way around that for Qt?Use proper export macros and/or create a cmake bug report.
Using the correct macros will also help the compiler / optimizer and the link & loading speed on linux./edit: See the documentation about static symbols - so no need to create a bug report.
-
Hey, I am using Qt 6.5 and cmake and I am looking for a way to export all symbols from my dlls, without needing to manually add macros to them. I am aware that there is
WINDOWS_EXPORT_ALL_SYMBOLSfor cmake, but this doesn't seem to export metaobjects, thus giving me errors that tell me that linking those failed.
Is there a solution to this that also links the Qt metaobjects?Thanks in advance.
@Creaperdown What problem are you trying to solve? I ask because this looks like an XY Problem.
If you want the QMetaObject of any QObject object then just call
object->metaobject(). -
@Creaperdown What problem are you trying to solve? I ask because this looks like an XY Problem.
If you want the QMetaObject of any QObject object then just call
object->metaobject().@ChrisW67 My application is composed from multiple layers, separated as dlls. Dlls on linux automatically export their symbols, dlls on windows dont, so I would need to add export macros to all my classes and functions, which I'd like to avoid.
My question is, if there is a way to, likeWINDOWS_EXPORT_ALL_SYMBOLSto export all symbols by default.WINDOWS_EXPORT_ALL_SYMBOLSdoes not work for metaobjects, as mentioned in my post. -
@ChrisW67 My application is composed from multiple layers, separated as dlls. Dlls on linux automatically export their symbols, dlls on windows dont, so I would need to add export macros to all my classes and functions, which I'd like to avoid.
My question is, if there is a way to, likeWINDOWS_EXPORT_ALL_SYMBOLSto export all symbols by default.WINDOWS_EXPORT_ALL_SYMBOLSdoes not work for metaobjects, as mentioned in my post.Apart from the fact that WINDOWS_EXPORT_ALL_SYMBOLS is imho a hack for lazy devs - please provide a minimal, compilable example. I don't see why the metaobject stuff should not be exported.
-
Apart from the fact that WINDOWS_EXPORT_ALL_SYMBOLS is imho a hack for lazy devs - please provide a minimal, compilable example. I don't see why the metaobject stuff should not be exported.
@Christian-Ehrlicher I have previously added the export macro to all classes, which worked, but I would prefer not to need these macros.
I have now removed them again to get back to the error back, and even though I set:
set(WINDOWS_EXPORT_ALL_SYMBOLS ON)at the top of the CMakeLists.txt that creates thedomainsymbols I get:Unresolved external symbol ""public: static struct QMetaObject const domain::entities::User::staticMetaObject" (?staticMetaObject@User@entities@domain@@2UQMetaObject@@B)". [C:\Users\prt np\Librum\build\src\application\application.vcxproj] -
@Christian-Ehrlicher I have previously added the export macro to all classes, which worked, but I would prefer not to need these macros.
I have now removed them again to get back to the error back, and even though I set:
set(WINDOWS_EXPORT_ALL_SYMBOLS ON)at the top of the CMakeLists.txt that creates thedomainsymbols I get:Unresolved external symbol ""public: static struct QMetaObject const domain::entities::User::staticMetaObject" (?staticMetaObject@User@entities@domain@@2UQMetaObject@@B)". [C:\Users\prt np\Librum\build\src\application\application.vcxproj]@Christian-Ehrlicher I am pretty sure that there is a limitation of
WINDOWS_EXPORT_ALL_SYMBOLS, namely that it can not export static symbols. Do you know some way around that for Qt? -
@Christian-Ehrlicher I am pretty sure that there is a limitation of
WINDOWS_EXPORT_ALL_SYMBOLS, namely that it can not export static symbols. Do you know some way around that for Qt?Use proper export macros and/or create a cmake bug report.
Using the correct macros will also help the compiler / optimizer and the link & loading speed on linux./edit: See the documentation about static symbols - so no need to create a bug report.
-
C Creaperdown has marked this topic as solved on