1. 程式人生 > >用arm-linux-gcc交叉編譯 openssl zlib curl

用arm-linux-gcc交叉編譯 openssl zlib curl

參考了大牛文章:

準備工作:
1. ubuntu 系統
2. 下載 arm-linux-gcc-4.3.2.tgz 放到 /opt

cd /opt

wget http://www.arm123.com.cn/linux/arm-linux-gcc-4.3.2.tgz    <- 這個是arm linux gcc 4.3.2 的下載地址

tar zxvf arm-linux-gcc-4.3.2.tgz -C /

每重新進入一次shell都要執行一下這幾句

export LD_LIBARY_PATH=/usr/local/arm/4.3.2/lib/
export CPPFLAGS=-I/usr/local/arm/4.3.2/include/
export LDFLAGS=-L/usr/local/arm/4.3.2/lib/
export CC=/usr/local/arm/4.3.2/bin/arm-linux-gcc

安裝openssl
cd /opt
wget http://www.openssl.org/source/openssl-0.9.8q.tar.gz
tar zxvf openssl-0.9.8q.tar.gz
cd openssl-0.9.8q
./config no-asm --prefix=/opt/openssl os/compiler:/usr/local/arm/4.3.2/bin/arm-linux-gcc
make
make install

安裝zlib
cd /opt
wget http://zlib.net/zlib-1.2.5.tar.bz2
tar xf zlib-1.2.5.tar.bz2
cd zlib-1.2.5
./configure --prefix=/opt/zlib
    //這裡要檢查Makefile的CC是不是設的 /usr/local/arm/4.3.2/bin/arm-linux-gcc
make
make install

安裝curl(依賴openssl)
cd /opt
wget http://curl.haxx.se/download/curl-7.21.3.tar.gz
tar zxvf curl-7.21.3.tar.gz
cd curl-7.21.3
./configure --host=i686 --target=arm-linux --prefix=/opt/curl/ --with-ssl=/opt/openssl --with-random=/dev/urandom

其中,加粗部分/opt/curl/表示curl安裝的路徑,我使用的是NFS檔案系統來進行OK6410開發,所以替換為了:--prefix=/monitor/FileSystem-Yaffs2/opt,即對應於開發板的/opt目錄。


make
make install

然後我們會發現在/monitor/FileSystem-Yaffs2/opt目錄下會有以下內容:

drwxrwxrwx  4 root root 4096  5月  2  2012 3G/
drwxr-xr-x  2 root root 4096  2月 25 18:24 bin/
drwxr-xr-x  3 root root 4096  2月 25 18:24 include/
drwxrwxrwx  3 root root 4096  2月 13  2011 konqueror/
drwxr-xr-x  3 root root 4096  2月 25 18:24 lib/
drwxrwxrwx  9 root root 4096  5月 11  2012 qt-4.7.1/
drwxrwxrwx 12 root root 4096 11月 15  2011 Qtopia/
drwxr-xr-x  3 root root 4096  2月 25 18:24 share/
drwxrwxrwx  2 root root 4096  3月  8  2011 WiFi/

然後進入bin目錄,將curl檔案拷貝至/monitor/FileSystem-Yaffs2/bin