Linux下编译webrtc所遇到的坑

环境:

CentOS release 6.8 (Final) x86_64 x86_64

Linux host.localdomain 4.10.5-1.el6.elrepo.x86_64 #1 SMP Wed Mar 22 14:55:33 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

 

gcc:

gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 

 

python:1.7.1

安装google webrtc官网安装步骤安装:https://webrtc.org/native-code/development/
 ​​

mkdir webrtc-checkout​

cd webrtc-checkout 

fetch --nohooks webrtc 

gclient sync​

 

1、python需要升级到2.7.*,否则fetch的时候报python语法错误

参考https://www.cnblogs.com/zhangxiaoliu/p/6180487.html

注意升级完python后,一定要更改yum的目录为旧的python

修改后系统 Python 软链接指向 Python2.7 版本,由于CentOS 6.5 的yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本。

  vim /usr/bin/yum

  把第一行的#!/usr/bin/python 修改为#!/usr/bin/python2.6.6

2、git当前版本:git version 1.7.1

升级到2.*

否则git -c会报错​

参考:http://blog.csdn.net/ei__nino/article/details/73504313​

安装git中还会遇到各种问题,参考:http://834945712.iteye.com/blog/1938789​

最后需要做软连接:ln -s /usr/local/bin/git /usr/bin/git

最后查看git版本:git version 2.13.1

3、接下来fetch遇到的问题:

________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://webrtc.googlesource.com/src.git /root/webrtc-checkout/_gclient_src_PDICMb' in '/root/webrtc-checkout'

[0:00:00] Cloning into '/root/webrtc-checkout/_gclient_src_PDICMb'...

[0:00:00] fatal: Unable to find remote helper for 'https'

参考:https://yq.aliyun.com/articles/23876​

注意:编译后安装发现没有可执行文件: git-remote-https 

还是会报错​

解决办法:yum install curl-devel​

重新configure,make,make install一次

 

至此,fetch问题全部解决,享受下载的快感吧,推荐用境外服务器,原因你懂的,链接google几十兆的下载速度​

 

4、接下来执行 gclient sync

tar (child): xz: Cannot exec: No such file or directory

tar (child): Error is not recoverable: exiting now

tar: Child returned status 2

 

因为tar缺少xz格式的解压工具

解决:yum install xz​

5、开始编译!

第四步还需要占用一定的时间,因为需要下载

 

gn gen out/Default

提示:

 

/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /root/webrtc-checkout/src/buildtools/linux64/gn)

/lib64/libc.so.6: version `GLIBC_2.15' not found (required by /root/webrtc-checkout/src/buildtools/linux64/gn)

 

解决:升级glibc

参考:http://www.voidcn.com/article/p-ptaystez-up.html

wget http://ftp.gnu.org.ua/gnu/libc/glibc-2.15.tar.gz

wget http://ftp.gnu.org.ua/gnu/libc/glibc-ports-2.15.tar.gz

这个编译过程很久,我这里一次成功了

[root@host glibc-build-2.15]# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_PRIVATE

 

发现已经升级到2.15版本了

6、真正编译:ninja -C out/Default

晕,竟然提示

../../third_party/llvm-build/Release+Asserts/bin/clang++: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by ../../third_party/llvm-build/Release+Asserts/bin/clang++)
../../third_party/llvm-build/Release+Asserts/bin/clang++: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by ../../third_party/llvm-build/Release+Asserts/bin/clang++)
../../third_party/llvm-build/Release+Asserts/bin/clang++: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by ../../third_party/llvm-build/Release+Asserts/bin/clang++)
../../third_party/llvm-build/Release+Asserts/bin/clang++: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by ../../third_party/llvm-build/Release+Asserts/bin/clang++)
../../third_party/llvm-build/Release+Asserts/bin/clang++: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ../../third_party/llvm-build/Release+Asserts/bin/clang++)

早知道在上一部就升级到3.4,真是服了

需要升级到4.8.1 支持c++11

参考:

https://github.com/qiwsir/ITArticles/blob/master/Linux/upgrade_gcc_on_Centos.md

http://www.linuxidc.com/Linux/2015-01/112595.htm

 

我直接用的make

遇到错误:

configure: error: C++ compiler missing or inoperational

是因为这台新机器上没有安装g++,只安装了gcc

yum install gcc-c++

然后再make,

after a long long time,编译完成了,这时查看gcc -v,咦,还是旧版本,此时需要reboot!!!,貌似不符合linux风格啊,但事实就是这样,reboot后,gcc-v,已经神奇的变成gcc version 4.8.1 (GCC) 了

 

但是,strings /usr/lib64/libstdc++.so.6 | grep GLIBC

你会发现lib库还是旧的,此时要替换

编译好的新库在这里:/usr/local/lib64/libstdc++.so.6.0.18

删掉旧的/usr/lib64/libstdc++.so.6,放心那只是个软连接,重新做一个指向libstdc++.so.6.0.18,原来的指向libstdc++.so.6 -> libstdc++.so.6.0.13

命令如下:

$ cp /usr/local/lib64/libstdc++.so.6.0.18 /usr/lib64 
$ cd /usr/lib64/
$ rm -f ./libstdc++.so.6
$ ln -s libstdc++.so.6.0.18 libstdc++.so.6

重新查看lib版本:

[root@host src]# strings /usr/lib64/libstdc++.so.6 |grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBC_2.3
GLIBC_2.2.5
GLIBC_2.14
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

至此,g++和库都升级完毕,这一圈折腾完,系统已经用了10几个g了,下载webrtc、组件、以及升级各种东西,下面应该可以好好的进入正题,编译webrtc了,谷歌真是大坑、神坑啊

好了,继续ninja编译,又after long long time

报错:

clang++: error: unable to execute command: Killed
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.0 (trunk 318667)
Target: x86_64-unknown-linux-gnu

据说是SWAP区不够的原因,解决办法参考:http://blog.csdn.net/honour2sword/article/details/43916505

解决方法:
请加大分区:
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
开机自动挂载swap:
使用 vi 或 nano 在 /etc/fstab 文件底部添加如下内容:
/swapfile none swap sw 0 0

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值