2、交叉編譯glib

2、交叉編譯glib

目標平臺:LOONGSON-1B開發板

內核:Linux 3.0

編譯平臺:ubuntu10.04

交叉工具鏈:gcc-3.4.6-2f

、簡介

    Glib庫是Linux平臺下最常用的C語言函數庫,它是GTK+和Gnome的基礎,提供基本的容器、算法、對象系統、OSAPI的適配器等。

二、下載Glib源碼包

    進入http://ftp.gnome.org/pub/gnome/sources/glib/下載一個Glib穩定版本源碼包,這裏選擇glib-2.24.4.tar.gz。

三、交叉編譯glib步驟

#tar jxf glib-2.24.2.tar.bz2

#cd glib-2.24.2

#./configure --prefix=/home/tools/gtk/glib_install --host=mipsel-linux CPPFLAGS='-I/home/tool/gtk/zlib_install/include' LIBS='-L/home/tool/gtk/zlib_install/lib'

出現錯誤:

checking for growing stack pointer... Configure:error:in '/home/tool/gtk/glib-2.24.2':

configure: error: cannot run test program while cross compiling

錯誤分析:由於configure不能爲交叉編譯檢查glib_cv_stack_grows等變量,configure無法在目標機上運行測試程序,只能手動指定,將不能自檢的變量全部寫入cache中,並重新配置:

#echo ac_cv_type_long_long=yes>mipsel-linux.cache

#echo glib_cv_stack_grows=no>>mipsel-linux.chche

#echo glib_cv_uscore=no>>mipsel-linux.chche

#echo ac_cv_func_posix_getpwuid_r=yes>>mipsel-linux.cache

#echo ac_cv_func_posix_getgrgid_r=yes>>mipsel-linux.cache

#./configure --prefix=/home/tools/glib_install --host=mipsel-linux CPPFLAGS='-I/home/tool/gtk/zlib_install/include' LIBS='-L/home/tool/gtk/zlib_install/lib' --cache-file=mipsel-linux.cache

配置成功後,make && make install

make過程中出錯錯誤giounix.c:185:錯誤:‘SSIZE_MAX’ undeclared(first used in this function) 

解決方法:在./glib/giounix.c加入SSIZE_MAX定義:

#define SSIZE_MAX 0x7fffffff

重新make && make install成功,在--prefix指定的目錄下生成需要移植的bin、lib、include和shared等目錄。

發佈了42 篇原創文章 · 獲贊 15 · 訪問量 38萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章