我已经为linux构建了webrtc,并使用
gn gen out/Default --args=is_debug=false rtc_use_h264=true target_cpu="x64" target_os="linux" clang_use_chrome_plugins=false use_ghash=false symbol_level=2 use_custom_libcxx=false is_component_ffmpeg=true ffmpeg_branding="Chrome" rtc_include_tests=false rtc_build_examples=true rtc_build_tools=false use_rtti=true rtc_enable_protobuf=false rtc_use_h264=true rtc_link_pipewire=true proprietary_codecs=true和
ninja -C . webrtc \
peerconnection_client但是,当我试图将静态webrtc与我的c++项目链接时,我得到了以下4个链接器错误:
1. test.cpp:(.text._ZN10H264BypassedEncoderC2ERKN7cricket10VideoCodecERNS_14DCVAgentClientE+0x191):
undefined reference to
`absl::EqualsIgnoreCase(std::basic_string_view<char,
std::char_traits<char> >, std::basic_string_view<char,
std::char_traits<char> >)'
2. CMakeFiles/webRTCserver.dir/src/audio/testEncoder.cpp.o:(.data.rel.ro._ZTVN10testEncoderE[_ZTVN10testEncoderE]+0xb8):
undefined reference to
`webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int,
std::optional<long>)'
3. testDecoderFactory.cpp/testEncoderFactory.cpp:(.text._ZN10testEncoderFactory20GetSupportedEncodersEv+0x20b): undefined reference to
`webrtc::SdpAudioFormat::SdpAudioFormat(std::basic_string_view<char,
std::char_traits<char> >, int, unsigned long,
std::map<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::less<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<std::pair<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >&&)'
4. H264BypassedEncoder.cpp.o:(.data.rel.ro._ZTVN10H264BypassedEncoderE[_ZTVN10H264BypassedEncoderE]+0x20):
undefined reference to
`webrtc::VideoEncoder::SetFecControllerOverride(webrtc::FecControllerOverride*)'当我在libwebrtc.a中查找符号时,类似的错误2如下所示:
nm --demangle libwebrtc.a | grep -i webrtc::AudioEncoder::OnReceivedUplinkBandwidth我得到以下输出:
0000000000000000 T webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)现在我不知道为什么nm显示输出的方式。但是使用ar -d libwebrtc.a <*.o>,我删除了所有的文件
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)我还在查链接器的错误。
除了webrtc::VideoEncoder::SetFecControllerOverride之外,其他未定义的引用错误也是如此,我不确定将提供哪个目标。
问题:
编辑:,如注释中建议的那样,为了尝试使用is_clang=false,我在构建libwebrtc.a文件时做了同样的工作,并得到了以下错误:
[5/2977] CXX obj/api/libjingle_peerconnection_api/sctp_transport_interface.o
FAILED: obj/api/libjingle_peerconnection_api/sctp_transport_interface.o
g++ -MMD -MF obj/api/libjingle_peerconnection_api/sctp_transport_interface.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCR_SYSROOT_HASH=e7c53f04bd88d29d075bfd1f62b073aeb69cbe09 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DWEBRTC_ENABLE_PROTOBUF=0 -DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE -DRTC_ENABLE_VP9 -DHAVE_SCTP -DWEBRTC_USE_H264 -DWEBRTC_LIBRARY_IMPL -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -I../.. -Igen -I../../third_party/abseil-cpp -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -pthread -m64 -march=x86-64 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Wall -Werror -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comments -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-unused-parameter -O2 -fno-ident -fdata-sections -ffunction-sections -fno-omit-frame-pointer -g2 -fvisibility=hidden -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -std=gnu++11 -Wno-narrowing -Wno-class-memaccess -fno-exceptions --sysroot=../../build/linux/debian_sid_amd64-sysroot -fvisibility-inlines-hidden -Wnon-virtual-dtor -Woverloaded-virtual -c ../../api/sctp_transport_interface.cc -o obj/api/libjingle_peerconnection_api/sctp_transport_interface.o
In file included from /usr/include/c++/7/utility:68:0,
from ../../api/sctp_transport_interface.cc:11:
/usr/include/c++/7/x86_64-redhat-linux/bits/c++config.h:3:10: fatal error: bits/wordsize.h: No such file or directory
#include <bits/wordsize.h>发布于 2020-07-18 16:12:19
我能够修复与链接构建的libwebrtc.a和构建的可执行工程相关的所有问题。
可以告诉我其他方法来调试错误1,2和3,因为libwebrtc.a中有符号
正在使用
cxx_std_17,所需的是cxx_std_14问题在于cxx_std_17的使用。在我正在构建的代码中,使用了某些默认cxx_std_11不可用的方法,所以我只使用了cxx_std_17,但是它给libwebrtc.a带来了很多问题。尽管webrtc风格指南说代码是有效的c++17,但是它面临着一些问题。在同一风格的指南中,有人提到webrtc代码是c++14编写的,这给我提供了切换到cxx_std_14和解决错误的想法。正如在同一webrtc风格指南中提到的那样,“代码的一些旧部分以各种方式违反了样式指南”。所以我认为是一些较旧的代码导致了错误
链接器错误1和3引用.cpp文件而不是.o文件的原因可能是什么,如错误2
我认为.cpp或.o背后的原因是,如果错误起源于我的代码,那么它显示的是.cpp,但是如果它在第三方库中,比如一些来自libwebrtc.a的链接器错误,那么它就会显示.o文件中的错误,因为库中只有编译的文件。
如何为webrtc构建找到忍者目标以解决错误4的未定义引用?
问题在于我试图建立的承诺。 从webrtc发布说明中,我找到了稳定的m77分支机构头提交,并发现我正在使用的提交没有链接器错误所指的函数,但是稳定m77分支的头提交具有这些功能。
注意:一般情况下,要获得具有所需符号的.o文件的目标,只需执行grep,它将列出定义符号相关函数的位置,ninja -t targets all将显示所有目标。因此,只需转到相应的.ninja文件,并将所有.o文件复制到webrtc.ninja并再次构建libwebrtc.a。
https://stackoverflow.com/questions/62862429
复制相似问题