Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'rethrow_exception' is not a member of 'std' #648

Closed
Nadav-Ruskin opened this issue Mar 11, 2018 · 14 comments
Closed

'rethrow_exception' is not a member of 'std' #648

Nadav-Ruskin opened this issue Mar 11, 2018 · 14 comments
Labels

Comments

@Nadav-Ruskin
Copy link

Nadav-Ruskin commented Mar 11, 2018

Description

Trying to compile a header that uses rethrow_exception throws an error.

Steps to reproduce

  1. Install NDK. For comfort, I started out with an image from dockcross.
  2. Put catch.hpp in a directory. The file can be found here in /single_include/catch.hpp.
  3. Make hello_world.cpp in same directory:
#include "catch.hpp"

TEST_CASE("test 1")
{
REQUIRE(1==1);
}
  1. Compile, making sure to use the right flags.
[osboxes:/work/build] 1 $ /usr/arm-linux-androideabi/bin/arm-linux-androideabi-g++ -std=gnu++11 -o hello_world hello_world.cpp
In file included from hello_world.cpp:1:0:
catch.hpp: In member function 'std::string Catch::ExceptionTranslatorRegistrar::ExceptionTranslator<T>::translate(std::vector<std::unique_ptr<const Catch::IExceptionTranslator> >::const_iterator, std::vector<std::unique_ptr<const Catch::IExceptionTranslator> >::const_iterator) const':
catch.hpp:1798:7: error: 'rethrow_exception' is not a member of 'std'
       std::rethrow_exception(std::current_exception());
       ^
catch.hpp:1798:30: error: 'current_exception' is not a member of 'std'
       std::rethrow_exception(std::current_exception());
                              ^

The bug report guide says to try clang. I have little experience with clang. Did I call clang correctly?

[osboxes:/work/build] 1 $ /usr/arm-linux-androideabi/bin/clang++ -std=c++11 -o hello_world hello_world.cpp
/usr/arm-linux-androideabi/bin/../sysroot/usr/lib/../lib/crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::StringRef::StringRef(char const*)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::SourceLineInfo::SourceLineInfo(char const*, unsigned int)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::StringRef::StringRef(char const*)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::AssertionHandler(Catch::StringRef, Catch::SourceLineInfo const&, Catch::StringRef, Catch::ResultDisposition::Flags)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::StringRef::~StringRef()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::StringRef::~StringRef()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::handle(Catch::ITransientExpression const&)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::StringRef::~StringRef()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::StringRef::~StringRef()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::useActiveException()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::shouldDebugBreak() const'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::isDebuggerActive()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::reactWithoutDebugBreak() const'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::~AssertionHandler()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::isTrue(bool)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function ____C_A_T_C_H____T_E_S_T____0(): error: undefined reference to 'Catch::AssertionHandler::~AssertionHandler()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::makeTestInvoker(void (*)())'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::SourceLineInfo::SourceLineInfo(char const*, unsigned int)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::StringRef::StringRef(char const*)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::StringRef::StringRef(char const*)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::NameAndTags::NameAndTags(Catch::StringRef, Catch::StringRef)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::AutoReg::AutoReg(Catch::ITestInvoker*, Catch::SourceLineInfo const&, Catch::StringRef, Catch::NameAndTags const&)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function __cxx_global_var_init: error: undefined reference to 'Catch::AutoReg::~AutoReg()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function Catch::BinaryExpr<int const&, int const&>::~BinaryExpr(): error: undefined reference to 'Catch::ITransientExpression::~ITransientExpression()'
/tmp/hello_world-f8b656.o:hello_world.cpp:function Catch::BinaryExpr<int const&, int const&>::BinaryExpr(bool, int const&, Catch::StringRef, int const&): error: undefined reference to 'Catch::StringRef::StringRef(Catch::StringRef const&)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function Catch::ITransientExpression::ITransientExpression(): error: undefined reference to 'vtable for Catch::ITransientExpression'
/usr/arm-linux-androideabi/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
/tmp/hello_world-f8b656.o:hello_world.cpp:function Catch::BinaryExpr<int const&, int const&>::streamReconstructedExpression(std::ostream&) const: error: undefined reference to 'Catch::StringRef::StringRef(Catch::StringRef const&)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function Catch::BinaryExpr<int const&, int const&>::streamReconstructedExpression(std::ostream&) const: error: undefined reference to 'Catch::formatReconstructedExpression(std::ostream&, std::string const&, Catch::StringRef, std::string const&)'
/tmp/hello_world-f8b656.o:hello_world.cpp:function std::string Catch::Detail::stringify<int>(int const&): error: undefined reference to 'Catch::StringMaker<int>::convert(int)'
/tmp/hello_world-f8b656.o:hello_world.cpp:typeinfo for Catch::BinaryExpr<int const&, int const&>: error: undefined reference to 'typeinfo for Catch::ITransientExpression'
clang38++: error: linker command failed with exit code 1 (use -v to see invocation)

Issue linked to catchorg/Catch2#1219

Environment Details

  • NDK Version: Tested 13b, 14b, and 16b
  • Build sytem: make
  • Host OS: Debian
  • Compiler: GCC
  • ABI: armeabi
  • STL: GNU
  • NDK API level: 16
@DanAlbert
Copy link
Member

DanAlbert commented Mar 12, 2018

Compiler: GCC
STL: GNU

Both of these are wontfix. Switch to Clang and libc++.

@rprichard
Copy link
Collaborator

The dockcross tool is creating a standalone toolchain here, https://github.com/dockcross/dockcross/blob/966365e21cffaa3f40f98a8ebd3abaa13e65b1b2/android-arm/Dockerfile#L19-L32.

It should pass --stl libc++ to enable the libc++ STL.

Your invocation of Clang looks correct. I see the same undefined reference errors when I build your test case using Debian's g++ or clang++ compiler, though, so there's something wrong with your test case.

@Nadav-Ruskin
Copy link
Author

Thank you for your quick answer. I used --stl libc++ and clang, and it worked. I'll inform dockcross.

I had no idea that libc++ was required for proper c++11 support. Where is this documented?

@DanAlbert
Copy link
Member

#82

But more importantly, our changelog documents that gnustl and stlport are deprecated and will be removed in r18.

@Nadav-Ruskin
Copy link
Author

Nadav-Ruskin commented Mar 15, 2018

So on what release was C++11 support added to NDK for libc++? r13? Please consider adding that information to a more widely accessed reference, such as https://developer.android.com/ndk/guides/standalone_toolchain.html .

Something like:

Full C++11 support is only available using --stl=libc++, and only from versions x and above

Would save some grief.

@DanAlbert
Copy link
Member

DanAlbert commented Mar 15, 2018

https://android-review.googlesource.com/#/c/platform/ndk/+/641151

But note that make_standalone_toolchain.py defaults to doing what's in your best interest. It'll default to libc++ on r17 and gnustl prior to that. libc++ only became stable in r16, and the default wasn't going to change until that had some soak time.

@DanAlbert
Copy link
Member

@Nadav-Ruskin
Copy link
Author

Thanks, but it doesn't seem that the changes were published.

@DanAlbert
Copy link
Member

Looks like it got clobbered?

@DanAlbert DanAlbert reopened this Mar 18, 2018
@Nadav-Ruskin
Copy link
Author

Still not fixed.

@DanAlbert
Copy link
Member

Doc looks right to me. Just forgot to close it.

@DanAlbert DanAlbert reopened this Apr 4, 2018
@DanAlbert
Copy link
Member

Never mind, I was confusing the note about incomplete C++11 support with a different note.

@DanAlbert
Copy link
Member

Fixed now.

@Nadav-Ruskin
Copy link
Author

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants