We are trying to integrate Crashpad with our Qt application and have run into several errors. We built Crashpad and attempted to link it to our application using the following snippet from the .pro
file:
# 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
}
Upon building, we got a ton of linker errors similar to the following:
base.lib(base.file_path.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
We saw this post and decided to build Crashpad using the /MDd
flag. After copying the new libraries into the directory listed above building with Qt yielded the following error:
fatal error C1007: unrecognized flag '-Ot' in 'p2'
Why is MSVC throwing this error? We are building using the 14.0 MSVC toolset.
The issue here ended up being a toolset mismatch. Ninja built Crashpad using the MSVC 2019 toolset. The version of Qt installed on the machine in question was 5.14.2 which used a MSVC 2017 toolset. Once we installed the 5.15.0 kits and built with the MSVC 2019 build configuration this error went away.
Additionally, once we solved the previous errors 4 new errors appeared:
These errors were solved by linking with
Advapi32
:Edit: After revisiting this, we found another solution is to turn off Whole Program Optimization which allows you to mix and match versions of MSVC building Crashpad and Qt.
Turning off Whole Program Optimization can be done by adding
/GL-
toextra_cflags
. The following snippet works in Windows CMD (does not work in PowerShell):A sample Windows Qt application integrated with Crashpad can be found here.