具有 MingW 和“未定义引用”的应用程序插件错误
我有一个 Qt 应用程序,它使用 Q_DECL_EXPORT 来将主可执行文件的某些数据类型和函数标记为导出。同样,当我编译插件时,我用 Q_DECL_IMPORT 标记这些相同的符号来导入它们。
这在 Linux 上效果很好。我需要做的就是使用 -rdynamic
进行编译,一切顺利。 Visual Studio 2008 对我也很好,它很乐意为我的主可执行文件创建一个 .lib
文件,我只需将我的插件链接到该 .lib
,它现在就知道了当插件加载时,这些符号将在主应用程序中找到。
另一方面,事实证明 MingW 并不是那么有趣。主应用程序按预期编译顺利。但是由于“未定义的引用”错误,所有插件在链接期间都会失败,当然都是以 _imp__
开头。 有没有办法让 MingW 忽略这些错误,因为我知道它们在正确加载时会得到解决?
我尝试过诸如 -Wl,--unresolved-symbols=ignore-all 之类的标志
和 -Wl,--allow-shlib-undefined
无济于事。
我想将 MingW 添加到支持的编译器列表中,但我似乎无法让这一部分工作。当然,我不是第一个想要拥有一个从正在加载的应用程序中导入符号的插件的人!
I have a Qt application which uses Q_DECL_EXPORT
to mark certain data types and functions of my main executable as exported. Likewise, when I compile my plugins, I mark those same symbols with Q_DECL_IMPORT
to import them.
This has worked great on linux. All I need to do is compile with -rdynamic
and it goes well. Visual Studio 2008 has been good to me as well, it happily creates a .lib
file for my main execuable, I simply link my plugins to that .lib
and it now knows that those symbols will be found in the main application when the plugin is loaded.
MingW on the other hand is proving to be not so much fun. The main application as expected compiles without a hitch. But the plugins all fail during link time due to "undefined reference" error all of course starting with _imp__
. Is there a way to get MingW to ignore these errors since I know they will be resolved when properly loaded?
I have tried flags such as -Wl,--unresolved-symbols=ignore-all
and -Wl,--allow-shlib-undefined
to no avail.
I would like to add MingW to the list of supported compilers, but I can't seem to get this one part to work. Surely I am not the first person to want to have a plugin which imports symbols from the application it is being loaded into!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论