ubuntu编译webrtc并且搭建调试环境

目录

1.下载源码

2.下载稳定版本

3.生成工程

4.编译

5.vscode配置


1.下载源码

首先,下载depot_tools

mkdir webrtc
cd webrtc
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

然后,配置环境变量,后面需要用到的工具都在depot_tools文件夹里面

export PATH="$PATH:/home/xxxx/webrtc/depot_tools"

 获取webrtc源码,时间会比较长

fetch --nohooks webrtc

gclient sync

如果不想编译,只是看代码,可以直接下载源码,不需要depot_tools

https://webrtc.googlesource.com/src.git

源码下载完成以后,在src目录

开始安装依赖库

cd src

./build/install-build-deps.sh --no-chromeos-fonts

2.下载稳定版本

如果想下载稳定的webrtc版本,可以切换到相应的branch

git checkout -b 5615 remotes/branch-heads/5615

切换完成以后,需要同步以下

gclient sync

不同稳定版本对应关系可以参照

https://chromiumdash.appspot.com/branches

3.生成工程

cd src

gn gen out/Default

如果想用vscode单步调试,可以用以下命令

gn gen out/Default --args='is_debug=true rtc_include_tests=false treat_warnings_as_errors=false use_rtti=true is_component_build=false enable_iterator_debugging=false is_clang=false use_sysroot=false  use_custom_libcxx=false use_custom_libcxx_for_host=false  target_os="linux" target_cpu="x64"'

4.编译

cd src

ninja -C out/Default

5.vscode配置

安装vscode,调试用的文件launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "peerconnection_client",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/out/Default/peerconnection_client",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}

6、grpc链接报错

编译date_channel_benchmark报错,明明third_party里面有有个grpc的源码,不知道什么原因。临时不编译了吧,哪位大佬知道解决办法,可以留言指教一下。

FAILED: data_channel_benchmark 
"python3" "../../build/toolchain/gcc_link_wrapper.py" --output="./data_channel_benchmark" -- g++ -Wl,--fatal-warnings -Wl,--build-id -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -fuse-ld=gold -Wl,--threads -Wl,--thread-count=4 -m64 -Wl,--gdb-index -rdynamic -Wl,-z,defs -Wl,--as-needed -pie -Wl,--disable-new-dtags -o "./data_channel_benchmark" -Wl,--start-group @"./data_channel_benchmark.rsp" ./libgrpc++.so -Wl,--end-group  -latomic -ldl -lpthread -lrt -lX11 
../../third_party/grpc/src/include/grpcpp/support/slice.h:38: error: undefined reference to 'grpc_slice_unref'
../../third_party/grpc/src/include/grpcpp/support/slice.h:49: error: undefined reference to 'grpc_slice_malloc'
../../third_party/grpc/src/include/grpcpp/support/slice.h:133: error: undefined reference to 'grpc_slice_from_static_buffer'
../../third_party/grpc/src/include/grpcpp/support/byte_buffer.h:87: error: undefined reference to 'grpc_raw_byte_buffer_create'
../../third_party/grpc/src/include/grpcpp/support/byte_buffer.h:99: error: undefined reference to 'grpc_byte_buffer_destroy'
../../third_party/grpc/src/include/grpcpp/support/byte_buffer.h:130: error: undefined reference to 'grpc_byte_buffer_destroy'
../../third_party/grpc/src/include/grpcpp/support/byte_buffer.h:140: error: undefined reference to 'grpc_byte_buffer_copy'
../../third_party/grpc/src/include/grpcpp/impl/grpc_library.h:42: error: undefined reference to 'grpc_shutdown'
../../third_party/grpc/src/include/grpcpp/completion_queue.h:118: error: undefined reference to 'grpc_completion_queue_destroy'
../../third_party/grpc/src/include/grpcpp/completion_queue.h:322: error: undefined reference to 'grpc_completion_queue_pluck'
../../third_party/grpc/src/include/grpcpp/completion_queue.h:382: error: undefined reference to 'grpc_completion_queue_shutdown'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:70: error: undefined reference to 'grpc_slice_from_static_buffer'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:778: error: undefined reference to 'grpc_empty_slice'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:814: error: undefined reference to 'grpc_slice_unref'
../../third_party/grpc/src/include/grpcpp/server_context.h:448: error: undefined reference to 'grpc_call_failed_before_recv_message'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_reader.h:54: error: undefined reference to 'grpc_byte_buffer_reader_init'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_reader.h:62: error: undefined reference to 'grpc_byte_buffer_reader_destroy'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_reader.h:82: error: undefined reference to 'grpc_byte_buffer_reader_peek'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:67: error: undefined reference to 'grpc_raw_byte_buffer_create'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:74: error: undefined reference to 'grpc_slice_unref'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:103: error: undefined reference to 'grpc_slice_malloc'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:113: error: undefined reference to 'grpc_slice_buffer_add_indexed'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:133: error: undefined reference to 'grpc_slice_buffer_pop'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:138: error: undefined reference to 'grpc_slice_split_tail'
../../third_party/grpc/src/include/grpcpp/support/proto_buffer_writer.h:139: error: undefined reference to 'grpc_slice_buffer_add'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:914: error: undefined reference to 'grpc_call_unref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:927: error: undefined reference to 'grpc_call_unref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:893: error: undefined reference to 'grpc_call_ref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:969: error: undefined reference to 'grpc_call_start_batch'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:975: error: undefined reference to 'grpc_call_error_to_string'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:987: error: undefined reference to 'grpc_call_start_batch'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:914: error: undefined reference to 'grpc_call_unref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:927: error: undefined reference to 'grpc_call_unref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:893: error: undefined reference to 'grpc_call_ref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:969: error: undefined reference to 'grpc_call_start_batch'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:975: error: undefined reference to 'grpc_call_error_to_string'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:987: error: undefined reference to 'grpc_call_start_batch'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:893: error: undefined reference to 'grpc_call_ref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:975: error: undefined reference to 'grpc_call_error_to_string'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:893: error: undefined reference to 'grpc_call_ref'
../../third_party/grpc/src/include/grpcpp/impl/call_op_set.h:975: error: undefined reference to 'grpc_call_error_to_string'
../../third_party/grpc/src/include/grpcpp/impl/grpc_library.h:36: error: undefined reference to 'grpc_init'
../../third_party/grpc/src/include/grpcpp/completion_queue.h:250: error: undefined reference to 'grpc_completion_queue_factory_lookup'
../../third_party/grpc/src/include/grpcpp/completion_queue.h:250: error: undefined reference to 'grpc_completion_queue_create'
../../third_party/grpc/src/include/grpcpp/support/client_callback.h:716: error: undefined reference to 'grpc_call_arena_alloc'
../../third_party/grpc/src/include/grpcpp/support/async_stream.h:501: error: undefined reference to 'grpc_call_arena_alloc'
collect2: error: ld returned 1 exit status

注释:

找到src/webrtc.gni

将原来的代码

rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)

改为

#rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
rtc_enable_grpc = false

保存后,重新编译即可。

参考文献:

Development | WebRTCWebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple JavaScript APIs. The WebRTC components have been optimized to best serve this purpose.icon-default.png?t=N7T8https://webrtc.github.io/webrtc-org/native-code/development/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值