getsentry / sentry-native

Sentry SDK for C, C++ and native applications.
MIT License
403 stars 170 forks source link

Linux linking errors #1079

Open pierricgimmig opened 1 week ago

pierricgimmig commented 1 week ago

On Linux, I get:

git/sentry-native/src/backends/sentry_backend_crashpad.cpp:55: undefined reference tooperator delete(void*, unsigned long)'`

What fixed it for me was to link with stdc++:

CMakeLists.txt

-       set(_SENTRY_PLATFORM_LIBS "dl" "rt")
+       set(_SENTRY_PLATFORM_LIBS "dl" "rt" "stdc++")

external/crashpad/handler/CMakeLists.txt

diff --git a/handler/CMakeLists.txt b/handler/CMakeLists.txt
index b7ba49ec..c60e3ada 100644
--- a/handler/CMakeLists.txt
+++ b/handler/CMakeLists.txt
@@ -107,6 +107,7 @@ if(NOT IOS)
             crashpad_tools
             crashpad_util
             mini_chromium
+            stdc++
     )
supervacuus commented 1 week ago

Thanks for the report! We're building the Native SDK on many Linux setups and haven't had a situation where we need to specify a particular stdlib implementation (except if someone is required to use a specific implementation over an environmental default).

This is typically defined via your toolchain, and we'd love to keep the toolchain-preferred stdlib (as we do now) instead of enforcing libstdc++ for everyone (since that can lead to non-obvious behavior in toolchains that have other default stdlibs like libc++).

Can you provide more context on which setup (Linux distribution, toolchain packages, CMake config-phase output) you had to specify a C++ standard library? I know that some "embedded" toolchains require further specification (in which case, I recommend preparing a simple CMake toolchain file that includes everything you need).