Export all symbols from dlls on windows (including Qt metaobjects)

huangapple go评论114阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月23日 14:35:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76746919.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定