最近負責一個可視電話項目,公司資源有限,整個項目軟體隻有我一個人,暴汗!花了兩個星期去編譯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】