我们正在尝试将 Crashpad 与我们的 Qt 应用程序集成,但遇到了几个错误。我们构建了 Crashpad 并尝试使用来自 .pro
的以下片段将其链接到我们的应用程序。文件:
# Crashpad rules for Windows
win32 {
LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lbase
LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lclient
LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lutil
}
在构建时,我们得到了大量类似于以下的链接器错误:
base.lib(base.file_path.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
我们看到了这个 post并决定使用
/MDd
构建 Crashpad旗帜。将新库复制到上面使用 Qt 构建的目录中后,出现以下错误:fatal error C1007: unrecognized flag '-Ot' in 'p2'
为什么 MSVC 会抛出这个错误?我们正在使用 14.0 MSVC 工具集进行构建。
最佳答案
这里的问题最终是工具集不匹配。 Ninja 使用 MSVC 2019 工具集构建了 Crashpad。有问题的机器上安装的 Qt 版本是 5.14.2,它使用了 MSVC 2017 工具集。一旦我们安装了 5.15.0 套件并使用 MSVC 2019 构建配置进行构建,此错误就消失了。
此外,一旦我们解决了之前的错误,就会出现 4 个新错误:
util.lib(util.registration_protocol_win.obj) : error LNK2001: unresolved external symbol __imp_BuildSecurityDescriptorW
util.lib(util.registration_protocol_win.obj) : error LNK2001: unresolved external symbol ConvertStringSecurityDescriptorToSecurityDescriptorW
util.lib(util.registration_protocol_win.obj) : error LNK2001: unresolved external symbol __imp_BuildExplicitAccessWithNameW
base.lib(base.rand_util.obj) : error LNK2001: unresolved external symbol SystemFunction036
这些错误已通过与
Advapi32
链接解决。 :# Crashpad rules for Windows
win32 {
LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lbase
LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lclient
LIBS += -L$$PWD/Crashpad/Libraries/Windows/ -lutil
LIBS += -lAdvapi32
}
可以找到与 Crashpad 集成的示例 Windows Qt 应用程序 here .
关于c++ - 将 Crashpad 与 Windows Qt 应用程序集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62396117/