如何使用 Qt Creator (gcc/MinGW) 在 Windows 上构建 Google Breakpad?
给定:为 Qt Creator 编写的应用程序项目(4.7.4,仅限 Win32,gcc/MinGW)。
需要:插入著名的 Google Breakpad 库以从客户那里收集详细的故障转储。
我目前的发现如下:
- 有一个breakpad-qt项目,大约有两年了。它包含要使用 Qt Creator 构建的上游 Breakpad 源的子树,因此我尝试通过构建它来生成工作示例。
- 由于使用了 Microsoft 小型转储格式,breakpad 本身本质上依赖于 Windows SDK 中的
DbgHelp.h
。 DbgHelp.h
可以在 Windows SDK 标头中找到,但是 还包括一些来自 Visual Studio 的标头,据报道这些标头无法由 GCC/MinGW 编译(我认为 MSVS 编译器的语言扩展不兼容)。- google breakpad 包含 MSVS 解决方案文件(由 gyp 生成),并且可以通过 MSVS 轻松构建(我在 2008 和 2010 Express 版本上都取得了成功),生成一些与目标应用程序链接的
.lib
。 - 但上面编译的
.lib
文件不能被MinGWld
识别,因此无法与Qt项目链接。已知库格式不兼容。 - 不过,来自 MSVS 2008(而不是 2010)的
.lib
文件可以被 MinGW 工具(最新可用)中的reimp
工具理解,该工具旨在将库从 MSVS 格式转换为MinGW 可用格式。在我的例子中,符号似乎正确导出,还有一些.obj
文件,但重新编译的库(使用 MinGW 的dlltool
)仍然无法被 MinGWld< /代码>。
- 所有与
.lib
链接有关的麻烦都被另一个问题所阻止:Qt 项目中需要有效的标头才能编译客户端代码,而这些标头正是来自 Breakpad 的标头,包括DbgHelp。 h
,见上文!
目前我看到的开放替代方案:
- 将应用程序从 Qt/MinGW (Creator) 完全切换到 Qt/MSVS,这可以允许直接链接上游 Breakpad。我认为这就是 Qt + Breakpad 的可通过谷歌搜索的小用例成功的核心。
- 构建一些混合方法,其中应用程序像往常一样使用 Creator 构建,然后通过 MSVS 链接器与 Breakpad 链接。但再说一遍,标题!
- 从 Microsoft 标头中撕下 Breakpad 所需的最小闭包,以便使用纯 Qt Creator 进行编译。
有什么建议、现有经验吗?
Given: Application project written for Qt Creator (4.7.4, Win32 only, gcc/MinGW).
Needed: Plug in well-known Google breakpad library to gather verbose crash dumps from customers.
My current findings are as follows:
- there is breakpad-qt project out there, about two years old. It contains subtree of upstream breakpad sources to be built with Qt Creator, so I've tried to produce working example by building it.
- breakpad itself inherently depends on
DbgHelp.h
from Windows SDK, because of usage of Microsoft minidump format. DbgHelp.h
can be found in Windows SDK headers, but
further includes some headers from Visual Studio, which are reportedly could not be compiled by GCC/MinGW (incompatible language extensions by MSVS compiler, I suppose).- google breakpad includes MSVS solution files (produced by gyp), and is readily buildable by MSVS (I've succeeded with both 2008 and 2010 Express versions), producing some
.lib
s to be linked with target application. - but the
.lib
files compiled above are not understood by MinGWld
, so could not be linked with Qt project. It is known incompatibility of library formats. - though,
.lib
files from MSVS 2008 (and not 2010) are understood byreimp
tool from MinGW tools (latest available), which is intended to translate libraries from MSVS format to MinGW usable format. In my case the symbols are exported seemingly correctly, and some.obj
files too, but recompiled library (withdlltool
of MinGW) is still unlinkable by MinGWld
. - And all the fuss with
.lib
linkage is blocked with another problem: valid headers are required in Qt Project in order to compile client code, and these headers are exactly those from breakpad, includingDbgHelp.h
, see above!
Currently open alternatives I see:
- Entirely switch the application from Qt/MinGW (Creator) to Qt/MSVS, which could allow direct linking of upstream breakpad. I think this is the core of success of little googleable use cases of Qt + breakpad at all.
- Construct some some hybrid approach, where application is built as usual with Creator and later linked with breakpad by MSVS linker. But again, headers!
- Tear off a minimal closure of what breakpad needs from Microsoft headers in order to compile with pure Qt Creator.
Any suggestions, existing experiences?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉让您失望,QtBreakpad 集成尚未针对 MinGW 进行开发和测试。
Sorry to disappoint you, but the QtBreakpad integration has not been developed for and tested with MinGW.