After NDK update can't link due to undefined std::logic_error::logic_error

1,748 views
Skip to first unread message

Pete Stoppani

unread,
May 9, 2018, 3:09:40 PM5/9/18
to android-ndk
I just updated to the latest NDK in Android Studio and now I get the following error:

[53/53] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/x86_64/libnative-lib.so
FAILED: : && /Users/pete/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++  --target=x86_64-none-linux-android --gcc-toolchain=/Users/pete/Library/Android/sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/pete/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/pete/Library/Android/sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -D__ANDROID_API__=24 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -fexceptions -std=c++11 -Wall -Werror -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /Users/pete/Library/Android/sdk/ndk-bundle/platforms/android-24/arch-x86_64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -L/Users/pete/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86_64 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/x86_64/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o [ long list of .o files removed]  -llog -latomic -lm "/Users/pete/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/libgnustl_static.a" && :
/Users/pete/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

The project consists of primarily C code.  The only C++ code are a small handful of native interface files.  So, it seems only some NDK library would reference the undefined 'logic_error()' method which leads me to believe the new NDK requires a library that I'm now missing.

Any clues?

Thanks,
Pete

Glenn Kasten

unread,
May 9, 2018, 3:14:00 PM5/9/18
to android-ndk
Sorry this slipped through moderation.
Bug reports are off-topic.
Posting guidelines are at top of https://groups.google.com/forum/#!forum/android-ndk

Can you please file bug at https://github.com/android-ndk/ndk/issues with:

old NDK version
new NDK version
Android Studio version (I assume it is the same for old and new, but please state)
short snippet of code that produces the error

Thanks

Dan Albert

unread,
May 9, 2018, 4:33:11 PM5/9/18
to android-ndk
"/Users/pete/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/libgnustl_static.a" && :

Linked with gnustl.
 
/Users/pete/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'

Compiled with libc++.

The STLs are not mutually compatible. It looks like you have some external library that needs to be rebuilt. For the time being you can use `-DANDROID_STL=gnustl_(static|shared)`, but in r18 gnustl won't be an option any more, so it would be best to start tracking down these issues now.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/9a6253fe-7be1-4391-ac08-5cabb1977133%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gjs

unread,
May 10, 2018, 12:27:52 PM5/10/18
to android-ndk
Hi,

I had similar errors after the NDK update -

stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'

- eventually resolved ok after doing 'Refresh Linked C++ Projects' from the Android Studio Build Menu.

Regards

Pete Stoppani

unread,
May 10, 2018, 12:27:52 PM5/10/18
to android-ndk
I removed "-frtti -fexceptions" and it links fine now.  I don't know why it linked fine with the previous version of the NDK???

I didn't post is a bug because it isn't clear this is a NDK bug.

Thx,
Pete

Dan Albert

unread,
May 10, 2018, 12:54:46 PM5/10/18
to android-ndk, Andrew Ford
It sounds like it isn't, but perhaps a Studio bug? Andrew (CC'd) says this could be an issue with CMake picking up some but not all configuration changes (there are a handful of variables that CMake will not update between subsequent runs, and it sounds like one of those and one that *is* updated are out of sync).

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
Reply all
Reply to author
Forward
0 new messages