最近在编译libjingle库,将路过的坑记录下,使用scons编译。
环境:
ubuntu14.04
Python 2.7.6
1.下载libjingle库源码
#git clone git@github.com:vigsterkr/libjingle.git
2.下载third_party下的依赖工程
在github上下载的libjingle目录下有一个脚本 get_third_party.sh 执行该脚本./get_third_party.sh 如果没有权限使用chmod +x get_third_party.sh 给于可执行权限,此脚本好像目前只能正常下载expat。 srtp的源已经更改到github上,gtest需要翻墙下载。
srtp下载:
#cd talk/third_party/srtp
打开README可以看到This has been moved to https://github.com/cisco/libsrtp
那么首先移除srtp
#rm srtp -rf
#git clone https://github.com/cisco/libsrtp
#mv libsrtp srtp
如果上面的有问题请下载下面的地址:
http://libjingle.googlecode.com/files/srtp-cvs.zip
3. 下载scons-local
下载地址:
http://sourceforge.net/projects/scons/files/scons-src/2.0.1/scons-local-2.0.1.zip
解压到libjingle目录
#cd libjingle
#unzip scons-local-2.0.1.zip -d ./scons-local-2.0.1
设置环境变量
#export SCONS_DIR=/home/work/libjingle/scons-local-2.0.1/scons-local-2.0.1 (注意这个目录是scons子目录)
4.下载swtoolkit
下载地址:http://code.google.com/p/swtoolkit/downloads/detail?name=swtoolkit.0.9.1.zip
#unzip swtoolkit.0.9.1.zip
#export PATH_TO_SWTOOLKIT=/home/work/libjingle/swtoolkit
5.编译libjingle
确保已经安装的软件 libssl-dev, libasound2-dev and gtk+2.0 没有请使用apt-get安装
运行
#talk/third_party/expat-2.0.1/configure
#talk/third_party/srtp/configure (注意此srtp是librtsp的重命名)
#cd talk (这步很重要开始我一直在libjingle的目录下执行编译一直报错scons: *** No SConstruct file found)
#$PATH_TO_SWTOOLKIT/hammer.sh (编译)
注意直接执行上述命令会报
scons: Reading SConscript files ...
EnvironmentError: No tool named 'mc': not a Zip file:
我们需要打开main.scons修改部分参数
#vim main.scons
找到
tools = [
'atlmfc_vc80',
#'code_signing',
'component_targets_msvs',
'directx_9_0_c',
#'grid_builder',
'mc',
'midl',
'target_platform_windows'
],
注释'mc' 这一行 #'mc'.
再运行 $PATH_TO_SWTOOLKIT/hammer.sh
还会报错
cc1plus: all warnings being treated as errors
scons: *** [build/dbg/obj/base/linux.o] Error 1
scons: building terminated because of errors.
再修改main.scons
#vim main.scons
找到
CCFLAGS = [
'-Wall',
'-Werror',
'-Wno-switch',
'-fno-exceptions',
# Needed for a clean ABI and for link-time dead-code removal to work
# properly.
'-fvisibility=hidden',
# Generate debugging info in the DWARF2 format.
'-gdwarf-2',
# Generate maximal debugging information. (It is stripped from what we ship
# to users, so we want it for both dbg and opt.)
# Note that hammer automatically supplies "-g" for mac/linux dbg, so that
# flag must be filtered out of linux_dbg and mac_dbg envs below.
'-g3',
],
注释 '-Werror', #'-Werror',
继续报错:
build/dbg/lib/libvideorenderer.a(gtkvideorenderer.o): In function `GtkVideoRenderer':
/share/Vendors/libjingle-0.6.6/talk/session/phone/gtkvideorenderer.cc:53:undefined reference to `g_thread_init'
collect2: ld returned 1 exit status
---g_thread_init 在 gthread-2.0 库中,在 pkg-config 中除了 gtk+-2.0 之外还需要加上 gthread-2.0 一项。
修改文件libjingle.scons
#vim libjingle.scons
talk.Library(env, name = "videorenderer",
lin_srcs = [
"session/phone/gtkvideorenderer.cc",
],
lin_packages = [
"gtk+-2.0",
"gthread-2.0", //增加
],
)
注意:
编译不通过的时候可以通过修改libjingle.scons 删除某些不需要的模块
注释 “talk.App(env, name = “call”,…”这个段 这个是用于支持LinphoneMediaEngine的如果需要支持LinphoneMediaEngine 需要下载”MediaStreamer” library