Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error undefined reference to std::__ndk1 after update ndk revision 11

undefined reference to 'webrtc::CreateSessionDescription(std::__ndk1::basic_string, std::__ndk1::allocator > const&, std::__ndk1::basic_string, std::__ndk1::allocator > const&, webrtc::SdpParseError*)'

After updating android ndk revision 11, I get some problems. I could not build my project because of above it.

In Android Developer, I found that 'Changed libc++’s inline namespace to std::__ndk1 to prevent ODR issues with platform libc++.', but I cannot understand.

How can I fix it?

Thanks for helping me.

like image 995
Hong Young Taek Avatar asked Mar 21 '16 09:03

Hong Young Taek


2 Answers

I think my way is more or less tricky, but it works. I went into /ndk-root-path//sources/cxx-stl/llvm-libc++/libcxx/include, there is a file named '__config'. open it and find out all lines with '_LIBCPP_BEGIN_NAMESPACE_STD', this is where the inline namespace '__ndk1' added. So I just comment out all inline namespaces, like:

   352 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {//inline namespace _LIBCPP_NAMESPACE {
   353 #define _LIBCPP_END_NAMESPACE_STD  } //}
   354 #define _VSTD std//::_LIBCPP_NAMESPACE

   356 namespace std {
    //  inline namespace _LIBCPP_NAMESPACE {
    //  }
    }

There should be 4 or 5 pieces of these codes. after comment that, you can rebuild your ndk project, it should works.

like image 51
Yan Castor Avatar answered Sep 29 '22 17:09

Yan Castor


I had the error undefined reference to 'std::ndk 1::cout'

I fixed it by changing my gradle file to this:

externalNativeBuild {
    cmake {
        cppFlags "-DANDROID_STL=c++_shared"
    }
}
like image 23
Jan Moritz Avatar answered Sep 29 '22 16:09

Jan Moritz