gpt4 book ai didi

android - 在 Android NDK 项目中使用 webrtc-58 - 使用 QT 构建时为 "Undefined reference to CopyOnWriteBuffer"

转载 作者:行者123 更新时间:2023-11-30 05:07:39 36 4
gpt4 key购买 nike

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

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()

MYPROJECT_Core.Pro 的内容

QT  += core xml
QT -= gui

TARGET = MYPROJECT_Core
TEMPLATE = lib

DEFINES += MYPROJECT_CORE_LIBRARY

DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += NOMINMAX
DEFINES += ENABLE_RTC_EVENT_LOG


QMAKE_CFLAGS_WARN_ON -= -Wall
QMAKE_CXXFLAGS_WARN_ON -= -Wall
CONFIG += warn_off

android {
CONFIG += c++11
QMAKE_CXXFLAGS += -std=c++11

DEFINES += NDEBUG=1
DEFINES += WEBRTC_POSIX
DEFINES += WEBRTC_ANDROID

LIBS += -L$$PWD/../Libs/webrtc-58/lib/android/armeabi-v7a/jni/armeabi-v7a -ljingle_peerconnection_so
INCLUDEPATH += $$PWD/../Libs/webrtc-58/include
DEPENDPATH += $$PWD/../Libs/webrtc-58/include
}


SOURCES += \
main.cpp \

最佳答案

我的同事今天解决了这个问题。他用 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 - 在 Android NDK 项目中使用 webrtc-58 - 使用 QT 构建时为 "Undefined reference to CopyOnWriteBuffer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47264103/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com