英文:
Export all symbols from dlls on windows (including Qt metaobjects)
问题
我正在使用Qt 6.5和CMake,我正在寻找一种方法来导出我的dll中的所有符号,而无需手动添加宏。我知道CMake中有WINDOWS_EXPORT_ALL_SYMBOLS
,但似乎它不会导出元对象(metaobjects),因此导致链接失败的错误。是否有一种解决方案,可以同时链接Qt的元对象?
英文:
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_SYMBOLS
for 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?
答案1
得分: 0
, 但似乎不能导出元对象,因此会导致链接失败的错误。是否有解决方法,也可以链接 Qt 的元对象?
这与导出无关。您需要将生成的 moc_<filename>.cpp
包含在您的 <filename>.cpp
中,或者至少作为编译的一部分。确保 CMAKE_AUTOMOC
为 true/on。
英文:
> , 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?
This has nothing to do with exports. You need to have the generated moc_<filename>.cpp
included in your <filename>.cpp
or at least be part of the compilation. Be sure that CMAKE_AUTOMOC
is true/on.
答案2
得分: 0
我注意到cmake文档提到WINDOWS_EXPORT_ALL_SYMBOLS
选项不会自动导出全局和静态符号。这解释了为什么只有静态元对象没有正确导出。
英文:
I have noticed that the cmake documentation mentions that global and static symbols are not exported automatically with the WINDOWS_EXPORT_ALL_SYMBOLS
option. This explains why only the static meta objects are not exported correctly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论