How to build crashpad for Qt application
Asked Answered
S

2

9

I am developing Qt application and I would like to use crashpad to report crashes. I have downloaded sources and built them.

Now I would like to link those statically to my application.

When I go to out folder I see a lot of .a files. Which one should I choose?

> find ./out -name *.a 
./obj/handler/libhandler.a
./obj/snapshot/libsnapshot.a
./obj/snapshot/libtest_support.a
./obj/test/libtest.a
./obj/test/libgtest_main.a
./obj/test/libgmock_main.a
./obj/util/libutil.a
./obj/third_party/mini_chromium/mini_chromium/base/libbase.a
./obj/third_party/gtest/libgtest_main.a
./obj/third_party/gtest/libgtest.a
./obj/third_party/gtest/libgmock.a
./obj/third_party/gtest/libgmock_main.a
./obj/minidump/libminidump.a
./obj/minidump/libtest_support.a
./obj/client/libclient.a

Also I have built it using this command:

build/gyp_crashpad.py -Dmac_deployment_target=10.12

I do not know if I should add some parameters

Could someone please help?

Thanks in advance

Szymanowski answered 11/1, 2019 at 20:57 Comment(1)
Possibly of interest to you, this CMake / Nuget wrapper for Crashpad, likely easier and more straightforward to use in a build than the plain librariesMandelbaum
P
3

Build Crashpad via gn and ninja, where gn generates a build configuration, and ninja does the actual building.

For a macOS Qt application to generate minidumps and upload them to a remote server it will need to be linked with the Crashpad libraries libcommon.a, libclient.a, libutil.a, libbase.a, mig_output.a:

# Crashpad libraries
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lcommon
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lclient
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lbase
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lutil
LIBS += -L$$PWD/Crashpad/Libraries/MacOS/$$ARCH -lmig_output

The application will also need to be linked with the system library bsm, and frameworks AppKit and Security:

# System libraries
LIBS += -L/usr/lib/ -lbsm
LIBS += -framework AppKit
LIBS += -framework Security

Additionally, you'll need to package crashpad_handler with your application and ensure that it is available at runtime.

More information about building Crashpad can be found here.

An example macOS Qt application that has been integrated with Crashpad can be found here.

Pulvinus answered 30/4, 2020 at 14:35 Comment(0)
L
-1

Maybe type this in your code:

sys._excepthook = sys.excepthook

def my_exception_hook(exctype, value, traceback):
    # Print the error and traceback
    print(exctype, value, traceback)
    # Call the normal Exception hook after
    sys._excepthook(exctype, value, traceback)
    sys.exit(1)
# Set the exception hook to our wrapping function
sys.excepthook = my_exception_hook

Also, import sys. This Code prints the error and reports it.

Lincoln answered 28/4, 2020 at 5:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.