全部问候,C++ MinGW共享库问题(仅限Windows,适用于Linux)?
我为我的项目使用MinGW,QT和CMake。
如图中所示,我的项目有两个模块。
libRinzoCore.DLL - 共享库,其定义了一些抽象类和接口和application.This模块的某些核心功能用于实现动态插件(也共享其由应用程序自动加载的库) 。
Rinzo.exe - 主要应用程序。它使用“libRinzoCore”类。
“libRinzoCore”主要是使用QT对象开发的,并与QT库链接。
“Rinzo.exe”也使用QT库对象,有些未在“libRinzoCore”中使用。所以我必须将QT库和“libRinzoCore”链接到该可执行文件。
我可以编译“libRinzoCore”没有问题,而且它生成的两个文件“libRinzoCore.DLL”和“libRinzoCore.DLL.a”
但在编制“Rinzo.exe”它提供了以下的输出:
Linking CXX executable Rinzo.exe
Info: resolving IRzPlugin::staticMetaObject by linking to __imp___ZN9IRzPlugin16staticMetaObjectE (auto-import)
Info: resolving IRzViewerPlugin::staticMetaObject by linking to __imp___ZN15IRzViewerPlugin16staticMetaObjectE (auto-import)
Info: resolving IRzLayeringPlugin::staticMetaObject by linking to __imp___ZN17IRzLayeringPlugin16staticMetaObjectE (auto-import)
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols
from auto-imported DLLs.
[100%] Built target Rinzo
和执行时“Rinzo.exe”它与消息(这是来自日本的错误消息翻译)
“应用程序不能performe 正确地崩溃(0000005)。点击[确定] 取消“
这里是我的CMake文件
libRinzoCore:
http://www.keepandshare.com/doc/2199086/rinzocore-txt-august-31-2010-12-10-pm-2k?da=y
Rinzo.exe:
http://www.keepandshare.com/doc/2199085/rinzo-txt-august-31-2010-12-10-pm-5k?da=y
它的工作原理好,如果我编译“libRinzoCore”为一个静态库。 在Linux上运行良好。
任何提示?
非常感谢Kamil.You救了我的一天!!!! – 2010-08-31 09:19:06
Qt还提供了一组简化此步骤的宏。您可以在Qt文档的[Creating Shared Libraries](创建共享库)(http://doc.qt.io/qt-5/sharedlibrary.html)一章中找到这些建议。 – SGaist 2017-01-17 15:15:02