天天看點

glib 交叉編譯步驟

借鑒文章網址為

wiki.beyondlogic.org/index.php?title=Cross_Compiling_BlueZ_Bluetooth_tools_for_ARM    

編譯glib需要zlib  libffi兩個庫檔案我使用的庫版本為

 glib-2.45.3.tar.xz   libffi-3.2.1.tar.gz  zlib-1.2.8.tar.gz

下載下傳庫推薦網址  點選打開連結 http://www.filewatcher.com/

直接輸入   zlib-1.2.8.tar.gz  就可以找到所有的ftp下載下傳内容的連接配接

zlib

 ./configure --prefix=$(pwd)/install

Edit the makefile and prefix the build tools with arm-linux-gnueabi-.

CC=arm-linux-gnueabi-gcc
LDSHARED=arm-linux-gnueabi-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
CPP=arm-linux-gnueabi-gcc -E
AR=arm-linux-gnueabi-ar
RANLIB=arm-linux-gnueabi-ranlib      
Make and install:
       
make
make install      

libffi

libffi is the Portable Foreign Function Interface Library and is a prerequisite for building GLib. It is an interface that allows code written in one language to call code written in another language. Download, build and install:
wget ftp://sourceware.org/pub/libffi/libffi-3.0.13.tar.gz
tar -xzf libffi-3.0.13.tar.gz
cd libffi-3.0.13/
./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi  
make
make install      
下面的這個是推薦網址中給出的原話編譯glib的      

GLib

GLib is part of the GTK+ Project GLib requires zlib, libffi and glibc >= 2.18 to successfully build. If you are building on ubuntu 14.04, the arm-linux-gnueabi should come installed with glibc 2.19 hence we don't rebuild it. GLib requires the glib-genmarshal tool installed on your build system otherwise the following error is likey to result:
checking for glib-genmarshal... no
configure: error: Could not find a glib-genmarshal in your PATH
      
An easy way to resolve this is to install libglib2.0-dev:
sudo apt-get install libglib2.0-dev
      
To build Glib, download, build and install:
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.40/glib-2.40.0.tar.xz
tar -xJf glib-2.40.0.tar.xz
cd glib-2.40.0
./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig  glib_cv_stack_grows=no glib_cv_uscore=yes ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes 
make
make install      
我使用的是一下配置       
./configure --prefix=/home/lz/work/hi3536/arm_install --host=arm-hisiv400-linux-gnueabi PKG_CONFIG_PATH=/home/lz/work/hi3536/arm_install LIBFFI_CFLAGS='-I/home/lz/work/hi3536/arm_install/lib/libffi-3.2.1/include' LIBFFI_LIBS='-lffi -L=/home/lz/work/hi3536/arm_install/lib' ZLIB_CFLAGS='-I/home/lz/work/hi3536/zlib-1.2.8/install/include' ZLIB_LIBS='-lz -L/home/lz/work/hi3536/zlib-1.2.8/install/lib' glib_cv_stack_grows=no glib_cv_uscore=yes ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes
           
--prefix=/home/lz/work/hi3536/arm_install 是我的安裝目錄可以修改成--prefix=$(pwd)/install 習慣用這個
           
--host=arm-hisiv400-linux-gnueabi 我的編譯器,可以通過增加臨時變量例如
           
export PATH=/opt/hisi-linux-nptl/arm-hisiv400-linux/bin:$PATH
source /etc/profile
           
使得            
arm-hisiv400-linux-gnueabi-gcc 可以正常使用并且不需要手動修改Makefile以及config防止出錯編譯成gcc版本
           
PKG_CONFIG_PATH=/home/lz/work/hi3536/arm_install 是我根據這篇文章來設定的目錄,我将zlib以及libffi  install到這個目錄不知道有沒有用,貼出來隻是給一個參考
           
LIBFFI_CFLAGS='-I/home/lz/work/hi3536/arm_install/lib/libffi-3.2.1/include' 
           
LIBFFI_LIBS='-lffi -L=/home/lz/work/hi3536/arm_install/lib' 
           
這句是我指定libffi的頭檔案以及庫檔案位置
           
ZLIB_CFLAGS='-I/home/lz/work/hi3536/zlib-1.2.8/install/include'
           
ZLIB_LIBS='-lz -L/home/lz/work/hi3536/zlib-1.2.8/install/lib' 
           
同樣指定zlib的安裝目錄這個目錄是我以前交叉編譯安裝的目錄
           
glib_cv_stack_grows=no 
           
glib_cv_uscore=yes 
           
ac_cv_func_posix_getpwuid_r=yes 
           
ac_cv_func_posix_getgrgid_r=yes
           
這些是glib的編譯選項我了解是的
           
然後make 
           
make install 就可以成功了