2010年7月22日 星期四

交叉編譯openssh以取得sftp-server

要取得sftp-server,必須要編譯openssh

準備工作:
1. 下載openssh原始碼(版本不必太新,以接近本機上cross-compiler的released date為主,其這是很重要的觀念之一)
2. 下載openssl原始碼(因為需要header檔和.so檔,而apt-get只會得到x86的函式庫,所以要自己編出來)

開始編譯

Openssl:

1. 先到openssl的資料夾,下 ./config no-asm -shared --prefix=/home/terry/utility/openssl 產生Makefile

2. 到Makefile內,把gcc、ar、ranlib改為arm-linux-gcc、arm-linux-ar、arm-linux-ranlib

3. make 和 make install

4. 把lib和include資料夾內的東西複製到toolchain內的lib和include資料夾裡 如此一來函式庫與標頭檔全到齊了


Openssh:

1. 到openssh的資料夾,下./configure --host-arm-linux

2. 最後make即可!會在資料內看到sftp-server 記得要arm-linux-strip sftp-server 讓檔案小一點



後記

若要編成靜態,要下 ./configure --host=arm-linux --with-ldflags=-static

Reference
http://blog.chinaunix.net/u3/94212/showart_2210811.html

沒有留言:

張貼留言