使用 WebRTC 编译 ndk 项目

Compiling ndk project with WebRTC

我正在尝试将 WebRTC 的 c++ api 集成到我的项目中。我能够在 Windows.

上构建 libwebrtc 和 link

此项目是 cross-platform 目标项目,因此应使用 NDK 进行编译。但是当我包含 WebRTC headers 时,它会抱怨如下:

webrtc/p2p/base/icetransportinternal.h(141,42) :  error: no member named 'to_string' in namespace 'std'
webrtc/p2p/base/icetransportinternal.h(141,42) :  error: no member named 'to_string' in namespace 'std'
webrtc/p2p/base/transportchannel.h(66,42) :  error: no member named 'to_string' in namespace 'std'
webrtc/p2p/base/transportchannel.h(66,42) :  error: no member named 'to_string' in namespace 'std'

我知道std::to_string在NDK环境下不可用 (参见 Android ndk std::to_string support)。但奇怪的是,我已经为 Android 成功构建了 libwebrtc

如何解决这种情况?

https://github.com/ThePacific/webrtc-android-jni/tree/master/so "download all these files and put in your libs folder then directly use system.load("库名");

I know std::to_string is unusable in NDK environment (see Android ndk std::to_string support).

取决于您选择的STL;它适用于 libc++,但不适用于 gnustl (https://github.com/android-ndk/ndk/issues/82)。推测的 webrtc 是用 libc++ 构建的,而你正在使用 gnustl。