Qt
Last updated
Was this helpful?
Last updated
Was this helpful?
BugSplat has developed a sample application demonstrating a cross-platform Qt crash reporting solution with Crashpad. The MyQtCrasher sample application provides a good starting point for developers wishing to capture Windows, macOS, and Linux crashes. Additionally, the sample provides symbol upload that you can incorporate into your build tools to generate crash reports with fully symbolicated call stacks
The MyQtCrasher sample application is available on .
BugSplat leverages to provide crash reporting for macOS, Windows, and Linux Qt applications. Please see this for an in-depth guide that discusses how to build Crashpad.
For Windows, you'll need to build shared libraries for both Release (/MD
) and Debug (/MDd
) configurations. You'll also want to consider building with turned off (/GL-
). To build shared libraries, generate your Crashpad build using the following terminal command:
The snippet above works with Windows CMD, and depending on the terminal you're using, you might get various errors related to escape characters. If you choose to omit the /GL-
flag you must ensure that you build Crashpad with the same version of MSVC you use for building your Qt application otherwise your project . Setting the version of MSVC that builds Crashpad can be done by instead generating your configuration using the command gn gen out/Default --winsdk="10.0.19041.0" --ide="vs2017"
.
For more info on how to build Crashpad shared libraries on Windows, see this .
Once Crashpad has been built, you'll need to add the relevant include directories to your project. Copy all of the Crashpad .h
files to the directory $$PWD/Crashpad/Include/crashpad
where $$PWD
is your project's working directory. Add the include directories to your project by pasting the following snippet at the top of your project file:
Add values corresponding to your BugSplat database, application name, and version. Note these values, as they will be used to configure Crashpad later in the configuration process.
Next, link your app with the Crashpad libraries. Linking with the Crashpad libraries is platform-dependent.
Copy libcommon.a
, libbase.a
, libutil.a
, libclient.a
, and libmig_output.a
into $$PWD/Crashpad/Libraries/MacOS
. You'll need to link to versions of these libraries that were built to target either arm64
or x86_64
depending on which architecture your build targets. You'll also need to link with the system libraries libbsm
, AppKit.Framework
, and Security.Framework
. Add the following snippet to your project file to link with the aforementioned libraries:
You'll need to include a copy of the crashpad_handler
executable with your application. Again, be sure to copy the version of crashpad_handler
that targets either arm64
or x86_64
depending on what architecture you're targeting.
Copy crashpad_handler
to the $$PWD/Crashpad/Bin/MacOS
directory. Add the following snippet to the macx
section of your project file that copies the macOS crashpad_handler
to your project's build directory.
Copy base.lib
, common.lib
, client.lib
and util.lib
into $$PWD/Crashpad/Libraries/Windows
. You'll need to link with the system library Advapi32
. Add the following snippet to your project file to link with the aforementioned libraries:
Additionally, you'll need to ship a copy of the crashpad_handler.exe
executable with your application.
Copy crashpad_handler.exe
to the $$PWD/Crashpad/Bin/Windows
directory. Add the following snippet to the win32
section of your project file that copies the Windows crashpad_handler.exe
to your project's build directory.
Copy libbase.a
, libutil.a
, libcommon.a
and libclient.a
into $$PWD/Crashpad/Libraries/Linux
. The order in which you specify the Crashpad libraries to link is important! libcommon.a
, and libclient.a
must be specified first, then libutil.a
and finally libbase.a
. Add the following snippet to your project file to link with the aforementioned libraries:
Additionally, you'll need to ship a copy of the crashpad_handler
executable with your application. Copy crashpad_handler
to the $$PWD/Crashpad/Bin/Linux
directory. Add the following snippet to the linux
section of your project file that copies the Linux crashpad_handler
to your project's build directory.
To enable Crashpad in your application, you must configure the Crashpad handler with your BugSplat database, application name, and application version. The following is a macOS, Windows, and Linux-compatible snippet that will configure the Crashpad handler:
Add a call to initializeCrashpad
at your application's entry point.
To get function names and line numbers in your crash reports, you will need to generate and upload .sym
files to BugSplat. Crashpad .sym
files can be generated from a macOS .dSYM
file, a Windows .pdb
file or a Linux .debug
file.
To generate .dSYM
, .pdb
and .debug
files add the following to the project file:
BugSplat's symbol-upload executable can generate .sym
files as part of the symbol upload process. To generate .sym
files from your .dSYM
, .pdb
, and .debug
files, invoke symbol-upload with the -m
flag as demonstrated in the platform-specific examples below.
To generate and upload .sym
files as part of your build, create a symbols.sh
script that calls symbol-upload-macos
:
Call symbols.sh
from your QMAKE_POST_LINK
step:
To generate and upload .sym
files as part of your build, create a symbols.sh
script that calls symbol-upload-windows.exe
:
Call symbols.bat
from your QMAKE_POST_LINK
step:
To generate and upload .sym
files as part of your build, create a symbols.sh
script that calls symbol-upload-macos
:
Call symbols.sh
from your QMAKE_POST_LINK
step:
Force a crash in your application after Crashpad has been initialized:
Be sure to update the values for dbName
, appName
and appVersion
to values specific to your application. The Paths
class allows you to get platform-specific paths for Crashpad; its source can be found . To configure the paths to crashpad_handler
, metricsDir
, reportsDir
and attachment
you'll first want to find the location of your executable using the sample code below:
You can download the platform-specific symbol-upload executables on the .
If you downloaded symbol-upload-macos via a web browser, you will need to the file before you can run the symbol-upload command
.
After each build, you must re-upload symbol files. For best results, you should increment the version number each time you release your application. The dbName
, appName,
and appVersion
values from the section must match the values set for $$BUGSPLAT_DATABASE
, $$BUGSPLAT_APPLICATION
, and $$BUGSPLAT_VERSION
.
After each build, you must re-upload symbol files. For best results, you should increment the version number each time you release your application. The dbName
, appName,
and appVersion
values from the section must match the values set for $$BUGSPLAT_DATABASE
, $$BUGSPLAT_APPLICATION
, and $$BUGSPLAT_VERSION
.
After each build, you must re-upload symbol files. For best results, you should increment the version number each time you release your application. The dbName
, appName,
and appVersion
values from the section must match the values set for $$BUGSPLAT_DATABASE
, $$BUGSPLAT_APPLICATION
, and $$BUGSPLAT_VERSION
.
After you've submitted a crash report, navigate to the page. Click the link in the ID
column to see the details of your crash report. The following image is from our sample myQtCrasher
application: