当前位置: 首页 > 工具软件 > LinPhone > 使用案例 >

Linphone 的编译

乐正明辉
2023-12-01

最近负责一个可视电话项目,公司资源有限,整个项目软件只有我一个人,暴汗!花了两个星期去编译Linhone,终于分别在电脑主机和开发板上(Freescale i.mx27)成功编译出来。期间发现问题还真不少,百度资源有限,google能搜到很多关于linphone的问题解答,建议想研究怎样编译的人去看看。下面就把我的编译经验说一下。注:Linphone版本为1.7.1,较低版本的配置略有不同,请注意阅读说明文件。

主机编译

首先在主机上编译,开始没什么难度,照着网站说明先编译出Osip、Readline、Speex、FFMPEG、SDL等,然后就可以开始编译Linphone了。先生成配置文件,最好加--disable-strict选项,不让后面可能会把警告当错误处理。

./configure --disable-strict

然后就开始make。我在编译mediastream这一步时出现错误,上网找了很多质量,Linphone作者解答可能是FFMPEG版本有问题,但是我换了好多版本都一样出错。后来网上有人说在

mediastream2/test/Makefile
mediastream2/src/Makefile

两个文件里修改LIBS,加入 libavutil 库,即

LIBS = " -lavutil"

果然编译通过。后来网上有人成功编译后介绍了一下他的编译过程,发现他没这个问题,不过他在编译配置时用了 --prefilx=/usr 参数,我的是默认路径,即 /usr/local ,如果大家还是编译不出来可以试试修改默认路径试试。反正我就是编译出来了。

 

 

 

交叉编译

在主机上编译通过了就可以试试交叉编译了,我用的是Freescale提供的交叉编译工具,gcc版本4.1。下面的代码好多是我机子上的配置,大家要根据自己实际情况修改一下。其实Linphone的README.arm文件有介绍编译步骤,不过不详细,而且会出现好多问题。

首先要根据 ipkg/ipaq-config.site 文件修改,生产你自己的编译环境下的配置环境,如:

// mxc-config.site

HOSTCC=gcc

# Names of the cross-compilers
CC=arm-926ejs-linux-gcc
CXX=arm-926ejs-linux-g++

# The cross compiler specific options
CFLAGS="-O2 -fno-exceptions"
CXXFLAGS="-O2 -fno-exceptions"
CPPFLAGS="-O2 -fno-exceptions -I/armbuild/usr/include -I/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-sf-1/arm-926ejs-linux/arm-926ejs-linux/include"
LDFLAGS="-O2 -fno-exceptions -L/armbuild/usr/lib -L/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-sf-1/arm-926ejs-linux/arm-926ejs-linux/lib"

# Some other programs
AR=arm-926ejs-linux-ar
RANLIB=arm-926ejs-linux-ranlib
NM=arm-926ejs-linux-nm
LD=arm-926ejs-linux-ld
ac_cv_path_NM=arm-926ejs-linux-nm
ac_cv_func_setpgrp_void=yes
host=arm-926ejs-linux
prefix=/usr
#x_includes=/skiff/local/arm-linux/include/X11
#x_libraries=/skiff/local/arm-linux/lib/X11

# These are for GNU shellutils
jm_cv_have_proc_uptime=yes
jm_cv_func_working_gnu_strftime=yes

# Some options for ease of compiling python
# (these are left over from the agenda. Not checked for iPAQ)
#ac_cv_sizeof_int=4
#ac_cv_sizeof_char=1
#ac_cv_sizeof_short=2
#ac_cv_sizeof_float=4
#ac_cv_sizeof_double=8
#ac_cv_sizeof_pthread_t=4
#ac_cv_sizeof_long=4
#ac_cv_sizeof_void_p=4
#ac_cv_sizeof_long_long=8
#ac_cv_sizeof_off_t=4
#ac_cv_sizeof_fpos_t=4
#ac_cv_sizeof_time_t=4

# Some other stuff nobody knows why
#bad_forward=no
#LDSHARED='mipsel-linux-gcc -msoft-float -shared'
#ac_cv_malloc_zero=nonnull

# squeak wants this
# can't do misaligned access to doubles
ac_cv_double_align=no
# dunno what order doubles are in
ac_cv_double_order=no

ac_cv_header_wchar_h=no

# added by oku, for compiling glib:
glib_cv_has__inline=yes
glib_cv_has__inline__=yes
glib_cv_hasinline=yes
glib_cv_sane_realloc=yes
glib_cv_va_copy=no
glib_cv___va_copy=yes
glib_cv_va_val_copy=yes
glib_cv_rtldglobal_broken=no
glib_cv_uscore=yes
ac_cv_func_getpwuid_r=yes
glib_cv_sizeof_gmutex=24

#added by Simon Morlat, for compiling glib-2.2.x

glib_cv_stack_grows=no
ac_cv_func_posix_getpwuid_r=yes
glib_cv_use_pid_surrogate=yes

然后

export CONFIG_SITE = 路径/配置文件名称                      //这里设置你的配置文件

export ARM_INSTALL_TREE=/armbuild                          //设置编译后安装的目录

这里要注意了,在不同终端设置的变量是不共通的,即你在一个终端界面设置了一个变量,新打开一个终端,在新开的终端里是没有你刚才设置的变量的!

Cross compiling ncurses for ARM:
********************************
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --with-shared
make
make install DESTDIR=$ARM_INSTALL_TREE

 

Cross compiling readline for ARM:
*********************************
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-static
make
make install DESTDIR=$ARM_INSTALL_TREE

 

Cross compiling libosip for ARM:
********************************
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-static
make
make install DESTDIR=$ARM_INSTALL_TREE

 

Cross compiling Ogg for ARM:
********************************
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-static
make
make install DESTDIR=$ARM_INSTALL_TREE

 

Cross compiling speex for ARM:
********************************
First you need to remove ogg headers from your build system to avoid a dirty conflict between
your build machine binaries and the arm binaries. They are usually in a libogg-dev package (rpm or deb).
                        我的方法:                      mv /usr/include /usr/include1
                                                mv /usr/lib /usr/lib1
                        !!注意等下要把名字改回来

Then:
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-static --enable-fixed-point --enable-arm-asm
make
make install DESTDIR=$ARM_INSTALL_TREE

 

FFMPEG
********************************
./configure --cross-prefix=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-sf-1/arm-926ejs-linux/bin/arm-926ejs-linux- /
               --prefix=/usr --cross-compile --arch=arm --target-os=arm-926ejs-linux --disable-static --enable-shared --disable-opts /
               --disable-ffserver --disable-ffplay
make
make install DESTDIR=$ARM_INSTALL_TREE

 

Cross compiling Voribs for ARM:
********************************
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-docs /
--with-ogg=$ARM_INSTALL_TREE/usr
make
make install DESTDIR=$ARM_INSTALL_TREE


这步可能会出现下面的错误:

collect2: ld returned 1 exit status
make[2]: *** [decoder_example] Error 1
make[2]: Leaving directory `/root/armbuild/libvorbis-1.2.0/examples'

解决办法:

vim Makefile


SUBDIRS = lib include doc examples vq

229 EXTRA_DIST = /
230                      CHANGES COPYING /
231                      todo.txt autogen.sh /
232                      libvorbis.spec libvorbis.spec.in /
233                      vorbis.m4 /
234                      vorbis.pc.in vorbisenc.pc.in vorbisfile.pc.in /
235                      vorbis-uninstalled.pc.in /
236                      vorbisenc-uninstalled.pc.in /
237                      vorbisfile-uninstalled.pc.in /
238                      doc examples symbian vq /
239                      macos macosx win32

中的examples删去

 






Cross compiling SDL for ARM:
********************************
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-static --disable-joystick --disable-cdrom /
--disable-ipod --disable-video-x11 --disable-esd
make
make install DESTDIR=$ARM_INSTALL_TREE

 

现在开始交叉编译Linphone,也是最关键的一步。

Cross compiling linphone for ARM
********************************
First you need to remove all .la files from the ARM_INSTALL_TREE because it confuses libtool and makes
the linker use your build machine binaries instead of the arm-crosscompiled ones.
rm -f $ARM_INSTALL_TREE/usr/lib/*.la
#for some reason pkg-config doesn't like cross-compiling...
export PKG_CONFIG=/usr/bin/pkg-config
./configure --prefix=/usr --host=arm-926ejs-linux --with-gnu-ld --disable-static --enable-gtk_ui=no /
--disable-glib --disable-strict /
--with-osip=$ARM_INSTALL_TREE/usr /
--with-prefix=$ARM_INSTALL_TREE/usr /
--with-realprefix=/usr /
--with-readline=$ARM_INSTALL_TREE/usr /
--with-ffmpeg=$ARM_INSTALL_TREE/usr /
--with-sdl=$ARM_INSTALL_TREE/usr /
FFMPEG_CFLAGS="-I$ARM_INSTALL_TREE/usr/include " /
FFMPEG_LIBS="-L$ARM_INSTALL_TREE/usr/lib " /
SPEEX_CFLAGS="-I$ARM_INSTALL_TREE/usr/include " /
SPEEX_LIBS="-L$ARM_INSTALL_TREE/usr/lib -lspeex "
make
make install DESTDIR=`pwd`/armbuild

如果出现以下错误:

checking SDL/SDL.h usability... yes
checking SDL/SDL.h presence... yes
checking for SDL/SDL.h... yes
checking for SDL_Init in -lSDL... no
configure: error: Could not find libsdl headers and library. This is mandatory for video support

可能是由于libvoribis库造成的,vim mediastream2/config.log 查找SDL,可以找到出错原因,可能是找不到 libvorbis.so.0 ,可是这文件明明就刚才编译后拷到了 /armbuild/usr/lib 文件夹,无论我怎么加入搜索库路径,还是说找不到。

解决办法是直接将 /armbuild/usr/lib 里面的库文件拷到编译器的库文件夹里面,其实只要ogg和vorbis库就可以了。如果后面还出现mediastream错误,用上面加入 -lavutil 参数的方法,反正我把库文件拷到编译器的库文件夹就没再出现这个错误了。

 

 

转自【http://www.rosoo.net/a/linux/201004/9216.html

 类似资料: