Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android NDK项目中使用webrtc-58;未定义对CopyOnWriteBuffer的引用;使用QT构建时_Android_C++_Qt_Android Ndk_Webrtc - Fatal编程技术网

在Android NDK项目中使用webrtc-58;未定义对CopyOnWriteBuffer的引用;使用QT构建时

在Android NDK项目中使用webrtc-58;未定义对CopyOnWriteBuffer的引用;使用QT构建时,android,c++,qt,android-ndk,webrtc,Android,C++,Qt,Android Ndk,Webrtc,我正在尝试为Android NDK构建一个共享库,该库引用了webrtc-58为Android构建的libjingle_peerconnection.so,但出现了链接器错误: MyProject\Libs\webrtc-58\include\webrtc\api\datachannelinterface.h:64: error: undefined reference to 'rtc::CopyOnWriteBuffer::~CopyOnWriteBuffer()' MyProject\Lib

我正在尝试为Android NDK构建一个共享库,该库引用了webrtc-58为Android构建的libjingle_peerconnection.so,但出现了链接器错误:

MyProject\Libs\webrtc-58\include\webrtc\api\datachannelinterface.h:64: error: undefined reference to 'rtc::CopyOnWriteBuffer::~CopyOnWriteBuffer()'
MyProject\Libs\webrtc-58\include\webrtc\base\copyonwritebuffer.h:48: error: undefined reference to 'rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(unsigned int, unsigned int)'
与我在Ubuntu和Windows上构建项目的输出相同。在Ubuntu上构建时,我将QT Creator配置为使用webrtc构建工具中的Android SDK/NDK(用于构建libjingle_peerconnection)

Qt5.9.2上的QT Creator 4.4.1 webrtc-58是使用以下配置在Ubuntu上构建的

gn gen out/Debug/arm-v7 --args='target_os="android" is_component_build=false rtc_include_tests=false target_cpu="arm"'
我已经转储了未压缩的libjingle_peerconnection.so,并注意到其中包含CopyOnWriteBuffer类实现:

001b2bbd t void rtc::CopyOnWriteBuffer::AppendData<unsigned char, (void*)0>(unsigned char const*, unsigned int)
000ee055 t rtc::CopyOnWriteBuffer::EnsureCapacity(unsigned int)
000edf51 t rtc::CopyOnWriteBuffer::CloneDataIfReferenced(unsigned int)
000fafd9 t char* rtc::CopyOnWriteBuffer::data<char, (void*)0>()
000fae61 t unsigned char* rtc::CopyOnWriteBuffer::data<unsigned char, (void*)0>()
000eddcd t rtc::CopyOnWriteBuffer::Clear()
00092cd1 t void rtc::CopyOnWriteBuffer::SetData<char, (void*)0>(char const*, unsigned int)
00092cd1 t void rtc::CopyOnWriteBuffer::SetData<unsigned char, (void*)0>(unsigned char const*, unsigned int)
000edb4d t rtc::CopyOnWriteBuffer::SetSize(unsigned int)
000fad19 t rtc::CopyOnWriteBuffer::operator=(rtc::CopyOnWriteBuffer&&)
000ed6f1 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(unsigned int)
000ed7d9 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(unsigned int, unsigned int)
000ed6e1 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(rtc::CopyOnWriteBuffer&&)
0003462f t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(rtc::CopyOnWriteBuffer const&)
0002f1f7 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer()
000faa35 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer<char, (void*)0>(char const*, unsigned int)
000ed6f1 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(unsigned int)
000ed7d9 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(unsigned int, unsigned int)
000ed6e1 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(rtc::CopyOnWriteBuffer&&)
0003462f t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer(rtc::CopyOnWriteBuffer const&)
0002f1f7 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer()
000faa35 t rtc::CopyOnWriteBuffer::CopyOnWriteBuffer<char, (void*)0>(char const*, unsigned int)
0003452d t rtc::CopyOnWriteBuffer::~CopyOnWriteBuffer()
0003452d t rtc::CopyOnWriteBuffer::~CopyOnWriteBuffer()

我不知道WebRTC-58,但我知道WebRTC 60有一个脚本可以为您构建Android LIB

python tools_webrtc/android/build_aar.py

这将为您配置一切,为x86、x86_64、arm和arm64构建,并将它们合并到libwebrtc.aar中,您可以将其添加到android项目中。

我的同事今天解决了这个问题。 他用webrtc构建输出中的另一个库替换了libjingle_peerconnection.so

obj/webrtc/api/libjingle_peerconnection_api.a
ob/webrtc/base/librtc_base_approved.a
QT Android Kit和webrtc构建系统也存在兼容性问题,所以Android Kit是用gnustl构建的,而webrtc是用libc++构建的,所以他从Android NDK捆绑包中包含了libc++_shared.so。 整个Pro文件将如下所示

QT       -= gui

TARGET = WebRtcDependantLib
TEMPLATE = lib

#CONFIG += c++11
QMAKE_CXXFLAGS += -fno-rtti -fno-exceptions
DEFINES += MY_TEST_LIBRARY

android {
    DEFINES += WEBRTC_POSIX
    DEFINES += WEBRTC_ANDROID


    DEFINES += NDEBUG

    WEBRTC = /home/user/Dev/src  #WEBRTC-M58 sources directory
    WEBRTCBUILD = $$WEBRTC/out/Debug/arm-v7/obj
    #android NDK bundled by webrtc build system
    WEBRTCNDK = $$WEBRTC/third_party/android_tools/ndk

    LIBS += -Wl,--start-group
    LIBS += $$WEBRTCBUILD/webrtc/api/libjingle_peerconnection_api.a
    LIBS += $$WEBRTCBUILD/webrtc/base/librtc_base_approved.a
    LIBS += -Wl,--end-group

    LIBS += $$WEBRTCNDK/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so 

    INCLUDEPATH += $$WEBRTC
    DEPENDPATH += $$WEBRTC
}
SOURCES += \
        main.cpp

谢谢你的建议,但是我正在构建Android NDK应用程序,似乎不能从Ac+LB中引用ALE LIB而不进行重新编译。h FielSoDo你只有<代码> Me.CPP < /Cord>源文件LIGBIGELYPEER C++。所以不导出C++类。它只显示java中调用的JNI函数。在任何WebRTC类中,您都必须使用libjingle_peerconnection.a。在一个项目中混合stl运行时是非常危险的,并且可能会导致难以分析的崩溃。您不能获得gnustl的rod吗?@AlexCohn,您是对的。编译该项目后,我们得到了具有随机崩溃的非常不稳定的应用程序。最后,我们必须使用clang工具构建QT-链,以将webrtc集成到QT项目中。
QT       -= gui

TARGET = WebRtcDependantLib
TEMPLATE = lib

#CONFIG += c++11
QMAKE_CXXFLAGS += -fno-rtti -fno-exceptions
DEFINES += MY_TEST_LIBRARY

android {
    DEFINES += WEBRTC_POSIX
    DEFINES += WEBRTC_ANDROID


    DEFINES += NDEBUG

    WEBRTC = /home/user/Dev/src  #WEBRTC-M58 sources directory
    WEBRTCBUILD = $$WEBRTC/out/Debug/arm-v7/obj
    #android NDK bundled by webrtc build system
    WEBRTCNDK = $$WEBRTC/third_party/android_tools/ndk

    LIBS += -Wl,--start-group
    LIBS += $$WEBRTCBUILD/webrtc/api/libjingle_peerconnection_api.a
    LIBS += $$WEBRTCBUILD/webrtc/base/librtc_base_approved.a
    LIBS += -Wl,--end-group

    LIBS += $$WEBRTCNDK/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so 

    INCLUDEPATH += $$WEBRTC
    DEPENDPATH += $$WEBRTC
}
SOURCES += \
        main.cpp