Undefined references for Sentry shared object?
-
My goal is to include Sentry-Native in an Android Quick project. However, when compiling, I keep getting undefined references for every Sentry function. Even with a minimal project, it produces this error.
Am I doing something wrong here?
I compiled Sentry-Native ahead of time as shared objects and included them in the app with this:
android:!equals(QT_ARCH, armeabi-v7a) { ANDROID_EXTRA_LIBS += $$PWD/sentry-libs/$${QT_ARCH}/libsentry_$${QT_ARCH}.so DEPENDPATH += $$PWD/sentry-libs/$${QT_ARCH} INCLUDEPATH += $$PWD/sentry-libs/include DEFINES += USES_SENTRY }
And at the beginning of the main function I am doing this:
#ifdef USES_SENTRY sentry_options_t *options = sentry_options_new(); sentry_options_set_dsn(options, "..."); sentry_init(options); sentry_capture_event(sentry_value_new_message_event( /* level */ SENTRY_LEVEL_INFO, /* logger */ "custom", /* message */ "It works!" )); // Make sure everything flushes auto sentryClose = qScopeGuard([] { sentry_close(); }); #endif
And here are the errors:
..\SentryTest/main.cpp:15: error: undefined reference to 'sentry_options_new' ..\SentryTest/main.cpp:16: error: undefined reference to 'sentry_options_set_dsn' ..\SentryTest/main.cpp:17: error: undefined reference to 'sentry_init' ..\SentryTest/main.cpp:19: error: undefined reference to 'sentry_value_new_message_event' ..\SentryTest/main.cpp:19: error: undefined reference to 'sentry_capture_event' ..\SentryTest/main.cpp:26: error: undefined reference to 'sentry_close' clang++: error: linker command failed with exit code 1 (use -v to see invocation)
-
ANDROID_EXTRA_LIBS is for deploying additional libraries and LIBS for linking to them.
Did you see the example in the documentation to include libraries for all ABIs ?
-
Hi,
From the looks of it, you don't link to that library.
-
From what I read, sounded like ANDROID_EXTRA_LIBS would be enough, as it loads the library already. I thought I had tried LIBS in addition before, but trying it again, it compiles, but is now outputting the following:
I zygote : Late-enabling -Xcheck:jni W zygote : Unexpected CPU variant for X86 using defaults: x86 W System : ClassLoader referenced unknown path: I QtCore : Start I Qt : qt started E AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread E AndroidRuntime: Process: org.qtproject.example.SentryTest, PID: 6208 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsentry_x86.so" not found E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:928) E AndroidRuntime: at java.lang.System.load(System.java:1621) E AndroidRuntime: at org.qtproject.qt5.android.QtNative$4.run(QtNative.java:505) E AndroidRuntime: at org.qtproject.qt5.android.QtThread$2.run(QtThread.java:87) E AndroidRuntime: at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61) E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
With this:
LIBS += -L$$PWD/sentry-libs/$${QT_ARCH} -lsentry_$${QT_ARCH}
And alternatively:
LIBS += $$PWD/sentry-libs/$${QT_ARCH}/ibsentry_$${QT_ARCH}.so
This is with an emulator instead of a physical device which may be changing the results (sadly can't be sure, the physical device is busy).
-
ANDROID_EXTRA_LIBS is for deploying additional libraries and LIBS for linking to them.
Did you see the example in the documentation to include libraries for all ABIs ?