1. 程式人生 > >mplayer移植

mplayer移植

轉自:http://bbs.gkong.com/archive.aspx?ID=286721    編譯器:arm-linux-gcc(4.3.2)     Pc平臺:ubuntu     在移植之前有必要先說明一下幾個問題:     Mplayer是自帶的mp3lib庫來進行mp3解碼的,但是arm系列的cpu,一般都沒浮點運算單元,而mplayer的mp3解碼預設使用mp3lib,這個是浮點運算庫,arm上肯定跑不了。所以使用libmad庫應該就沒問題了,所以需要提前移植libmad庫。  (1)準備工作  ①下載庫檔案libmad-0.15.1b.tar.gz並解壓到 /usr/local/libmad    ②下載Mplayer的tar包,官方下載地址

http://www.mplayerhq.hu,進去後在ftp裡面很多版本可以選,我選的最新的MPlayer-1.0rc4.tar.gz,大小12.3M。  ③準備編譯前請先確定已安裝交叉編譯器arm-linux-gcc(4.3.2),並已經在終端設定好環境變數,做好這些就可以開始移植工作了。  (2)編譯libmad  ①先下載壓縮包到本地,並解壓libmad-0.15.1b.tar.gz到/usr/local/libmad:  [email protected]: /usr/local/libmad # tar zxvf mysql-5.1.51.tar.gz  ②進入解壓得到的原始碼目錄中:       
[email protected]
: /usr/local/libmad # cd libmad-0.15.1b  ③執行configure,生成makefile:       [email protected]: /usr/local/libmad/libmad-0.15.1b #./configure CC=arm-linux-gcc --host=arm-linux --disable-shared --disable-debugging --prefix=/usr/local/libmab/mad   ④修改makefile:     [email protected]: /usr/local/libmad/libmad-0.15.1b #./gedit Makefile      找到裡面的“--fforce-mem”,然後刪除儲存退出即可  ⑤直接開始執行make編譯原始碼: 
[email protected]
: /usr/local/libmad/libmad-0.15.1b # make  (3)交叉編譯Mplayer  ①先下載壓縮包到本地,並解壓MPlayer-1.0rc4.tar.gz到/usr/local/mplayer:  [email protected]: /usr/local/mplayer # tar zxvf MPlayer-1.0rc4.tar.gz  ②進入解壓得到的原始碼目錄中:  [email protected]: /usr/local/mplayer # cd MPlayer-1.0rc4  ③執行configure,生成makefile:  [email protected]: /usr/local/mplayer/ MPlayer-1.0rc4#   ./configure --host-cc=gcc --cc=arm-linux-gcc --target=arm-linux --enable-fbdev --enable-static --disable-dvdread --disable-live --disable-mp3lib --enable-mad --disable-win32dll --disable-mencoder --disable-ivtv --disable-dvdnav --disable-dvdread-internal --disable-libdvdcss-internal --enable-libavcodec_a --prefix=/usr/local/Mplayer/mplayer 2>&1 | tee logfile  這個就是我的配置內容,這裡詳細說明一下:  --host-cc=gcc --cc=arm-linux-gcc --target=arm-linux   //這個不需要解釋  --enable-fbdev                           //開啟framebuffer支援.ARM開發板必須的  --enable-static                           //靜態編譯,編譯成功後只需要將exe檔案拷走即可以使用  --disable-dvdread --disable-dvdnav --disable-dvdread-internal //全部與DVD相關,無視即可  --disable-libdvdcss-internal        //這個不加低版本mplayer也會出錯  --disable-live                              //禁止流媒體,我們用不到  --disable-mp3lib --enable-mad  //關閉預設的MP3解碼庫,使用我們剛才編譯的libmad  --disable-win32dll                      //禁用win32動態連結庫支援  --disable-mencoder                   //交叉編譯mencoder會有問題,而且arm上不需要這個功能  --disable-ivtv                             //如果不加會出現ivtv檔案產生的錯誤    --enable-libavcodec_a               //啟用靜態的libavcodec解碼  --prefix=/usr/local/Mplayer/mplayer 2>&1 | tee logfile  //不解釋  特別說明:     注意!!configure裡面沒有下面2句:    --enable-static --with-extraincdir=/usr/local/libmab/mad/include        --with-extralibdir=/usr/local /libmab/mad/lib      本來是還要有這2句話來指定我們編譯的新的libmad的庫的,但是由於新下載的mplayer原始碼在配置的時候--with-extraincdir   –with-extralibdir提示沒有此配置選項,因此需手動新增libmad庫的支援,我的解決方法是將/ usr/local /libmab/mad/include下檔案直接拷貝到mplayer原始碼中,而對於其下面的庫libmad.a,則先執行上面的“執行configure”一步,會生成config.mak檔案,然後修改config.mak中在-lmad -L/usr/local /libmab/mad/lib,然後執行下一步即可。  ④修改Makefile.  修改MPlayer-1.0rc4/libmpeg2/motion_comp_arm_s.S檔案  [email protected]: /usr/local/mplayer/ MPlayer-1.0rc4#   gedit  /libmepg2/motion_comp_s.S  在最前加入:  #ifndef HAVE_PLD   .macro pld reg   .endm   #endif  ⑤直接開始執行make編譯原始碼:  [email protected]: /usr/local/mplayer/ MPlayer-1.0rc4# make  ⑥Make完成後,執行makeinstall命令,但是我遇到了如下問題:   [email protected]: /usr/local/mplayer/ MPlayer-1.0rc4# make install         install -m 755 -s mplayer /home/hxy/MPlayer/         MPlayer-1.0rc4/../mplayer/bin         strip: Unable to recognise the format of the input file         `/user/local/Mplayer/MPlayer-1.0rc4/../mplayer/bin/mplayer'  解決方法:   查資料看install帶-s 引數時會自動呼叫strip來strip應用程式。但是arm編譯時要呼叫arm-linux-strip才有正確處理。解決辦法是取消-s引數,檢視Makefile可以發現-s是如下  $(INSTALL) -m 755 $(INSTALLSTRIP) mplayer$(EXESUF)     $(BINDIR)     的INSTALLSTRIP設定的,它預設是-s,因此只要簡單在Makefile的install部分前面加入:  INSTALLSTRIP :=  #將其置為空即可  ⑥再次執行makeinstall命令,生成mplayer:     [email protected]: /usr/local/mplayer/ MPlayer-1.0rc4# make install  附帶一個只有影象沒有聲音的錯誤解決辦法:  mkdir -p /dev/sound   ln -s /dev/dsp /dev/sound/   原因:目標系統上有 /dev/dsp 音訊裝置檔案,只是OSS音訊驅動需要的是 /dev/sound/dsp 裝置檔案,這問題的簡單解決方法是建一個符號連結,當然這兩條命令可以寫在系統的啟動檔案的適當位置,即修改系統的/etc/init.d/rcS檔案。