ubuntu下交叉編譯lftp


一.背景:

lftp依賴於ncurses,readline和gnutls

二.准備工作

2.1交叉編譯ncurses

2.1.1獲取ncurses源碼

wget ftp://ftp.invisible-island.net/ncurses/ncurses.tar.gz

2.1.2解壓

tar xvf ncurses.tar.gz

2.1.3配置以生成Makefile

./configure CC=arm-linux-gnueabi-gcc --host=arm-linux-gnueabi --prefix=/home/jello/ncurses-5.9/__install

../configure  --host=arm-linux-gnueabi --prefix=$PWD/__install --with-shared

2.1.4 編譯

make

2.1.5 安裝

make install

2.2 交叉編譯readline

2.2.1獲取readline源碼

wget ftp://ftp.cwru.edu/pub/bash/readline-6.3.tar.gz

2.2.2 解壓

tar xvf readline-6.3.tar.gz

2.2.3生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install

2.2.4 編譯

make

2.2.5安裝

make install

2.3 交叉編譯gnutls

2.3.1 獲取gnutls源碼

git clone https://gitlab.com/gnutls/gnutls.git

cd gnutls

git submodule update --init

git checkout master

2.3.2 生成configure

autoreconf

2.3.2.1出現以下錯誤提示

configure.ac: error: required file 'build-aux/ylwrap' not found
configure.ac:   'automake --add-missing' can install 'ylwrap'
autoreconf: automake failed with exit status: 1

解決方案:

automake --add-missing

2.3.2.2創建編譯目錄,防止污染源碼

mkdir build

2.3.2.3 切換到編譯目錄

cd build

2.3.3 生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install

2.3.3.1 出現以下錯誤:

configure: error:
  ***
  *** Libnettle 3.1 was not found.

解決方案:

 安裝版本號為3.1的nettle庫(加密庫)

2.3.3.1.1 獲取nettle庫源碼

wget ftp.gnu.org/gnu/nettle/nettle-3.1.tar.gz

2.3.3.1.2 解壓nettle庫源碼

tar xvf nettle-3.1.tar.gz

2.3.3.1.3 切換到源碼目錄下

cd nettle-3.1

2.3.3.1.4 創建編譯目錄

mkdir build

2.3.3.1.5 切換到編譯目錄

cd build

2.3.3.1.6 生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install

2.3.3.1.7 編譯源碼

make -j4

2.3.3.1.8 安裝

make install

2.3.4 重新生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install  NETTLE_CFLAGS=-I/home/jello/nettle-3.1/build/__install/include NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle"

2.3.4.1 出現以下錯誤:

  *** Libhogweed (nettle's companion library) was not found. Note that you must compile nettle with gmp support.

解決方案:

2.3.4.1.1 在編譯nettle時加上gmp庫

前情提要:

nettle 是symmetric algorithms

hogweed 是public-key algorithms

nettle庫和hogweed庫組合起來就是Nettle low-level cryptographic library

2.3.4.1.2 重新交叉編譯nettle

2.3.4.1.2.1 切換到nettle源碼目錄下並將之前編譯的內容全部清除

cd nettle-3.1 && rm -rf build

2.3.4.1.2.2 創建編譯目錄

mkdir build

2.3.4.1.2.3 切換到編譯目錄

cd build

2.3.4.1.2.4 生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install CFLAGS=-I/home/jello/gmp-6.1.2/build/__install/include LDFLAGS=-L/home/jello/gmp-6.1.2/build/__install/lib LIBS=-lgmp   (gmp庫的編譯方法在后面)

2.3.4.1.2.5 編譯源碼

make -j4

2.3.4.1.2.6 安裝

make install

 

2.3.5 再次生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install NETTLE_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle" HOGWEED_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" HOGWEED_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lhogweed"

2.3.5.1 提示以下錯誤:

Libtasn1 4.9 was not found. To use the included one, use --with-included-libtasn1

解決方案:

2.3.5.1.1 將--with-included-libtasn1這個選項加入

2.3.6 重新生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install NETTLE_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle" HOGWEED_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" HOGWEED_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lhogweed" --with-nettle-mini --with-included-libtasn1

出現以下錯誤提示:

Libunistring was not found. To use the included one, use --with-included-unistring

解決方案:

2.3.6.1 將--with-included-unistring這個選項加入

2.3.7 重新生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install NETTLE_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle" HOGWEED_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" HOGWEED_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lhogweed" --with-nettle-mini --with-included-libtasn1 --with-included-unistring

出現以下錯誤:

checking for unbound library... no
configure: WARNING:
***
*** libunbound was not found. Libdane will not be built.
***
checking for P11_KIT... no
configure: error:
***
*** p11-kit >= 0.23.1 was not found. To disable PKCS #11 support
*** use --without-p11-kit, otherwise you may get p11-kit from
*** http://p11-glue.freedesktop.org/p11-kit.html

解決方案:

2.3.7.1 加入兩個選項--disable-libdane和-without-p11-kit

2.3.7.1.1 第一個選項就是不要編譯libdane庫,第二個選項就是不要加入p11-kit庫

2.3.8 重新生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install NETTLE_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle" HOGWEED_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" HOGWEED_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lhogweed"  --with-included-libtasn1 --with-included-unistring --disable-libdane -without-p11-kit

出現以下錯誤:

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: error: cannot find input file: `src/libopts/Makefile.in'

2.3.8.1 換成release版本試試,目前使用的是開發版本

 

2.3.9 獲取release版本

wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.5/gnutls-3.5.17.tar.xz

2.3.10 解壓

tar xvf gnutls-3.5.17.tar.xz

2.3.11 切換到源碼目錄

cd gnutls-3.5.17

2.3.12 創建編譯目錄

mkdir build

2.3.13 生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install NETTLE_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle" HOGWEED_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" HOGWEED_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lhogweed"  --with-included-libtasn1 --with-included-unistring --disable-libdane --without-p11-kit

2.3.14 編譯

make -j4

出現以下錯誤:

In file included from ../../../lib/nettle/pk.c:41:0:
../../../lib/nettle/int/dsa-fips.h:27:17: fatal error: gmp.h: No such file or directory
 #include <gmp.h>
                 ^
compilation terminated.
Makefile:1474: recipe for target 'pk.lo' failed

解決方案:

從以上錯誤可知gnutls還依賴於gmp庫,所以解決方案是編譯好gmp庫

2.3.14.1 獲取gmp庫

wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz

2.3.14.2 解壓gmp-6.1.2.tar.lz

lunzip gmp-6.1.2.tar.lz  (需要安裝lunzip這個軟件,ubuntu下的安裝方法: sudo apt-get install lunzip)

tar xvf gmp-6.1.2.tar

2.3.14.3 切換到解壓后的源碼目錄

cd gmp-6.1.2

2.3.14.4 創建編譯目錄build

mkdir build

2.3.14.5 切換到build目錄

cd build

2.3.14.6 生成Makefile

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install

2.3.14.7 編譯

make

2.3.14.8 安裝

make install

2.3.15 重新編譯gnutls,生成Makefile  (需要刪除之前gnutls的build目錄里的內容)

../configure --host=arm-linux-gnueabi --prefix=$PWD/__install GMP_CFLAGS="-I/home/jello/gmp-6.1.2/build/__install/include" GMP_LIBS="-L/home/jello/gmp-6.1.2/build/__install/lib -lgmp" NETTLE_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" NETTLE_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lnettle" HOGWEED_CFLAGS="-I/home/jello/nettle-3.1/build/__install/include" HOGWEED_LIBS="-L/home/jello/nettle-3.1/build/__install/lib -lhogweed" --with-included-libtasn1 --with-included-unistring --disable-libdane --without-p11-kit

2.3.16 編譯

make

此時會出現以下錯誤

eabi/4.8.3/../../../../armlinux-gnueabi/bin/ld: warning: libnettle.so.6, needed by ../lib/.libs/libgnutls.so, not found (try using -rpath or -rpath-link)
/opt/hisi-linux/x86-arm/arm--linux/bin/../lib/gcc/arm-linux-gnueabi/4.8.3/../../../../arm-linux-gnueabi/bin/ld: warning: libhogweed.so.4, needed by ../lib/.libs/libgnutls.so, not found (try using -rpath or -rpath-link)
/opt/hisi-linux/x86-arm/arm-linux/bin/../lib/gcc/arm-linux-gnueabi/4.8.3/../../../../arm-linux-gnueabi/bin/ld: warning: libgmp.so.10, needed by ../lib/.libs/libgnutls.so, not found (try using -rpath or -rpath-link)
../lib/.libs/libgnutls.so: undefined reference to `nettle_aes192_encrypt@NETTLE_6'
../lib/.libs/libgnutls.so: undefined referenc

 

2.3.15 安裝

 

 

 

三.交叉編譯lftp

3.1獲取lftp源碼

wget http://lftp.yar.ru/ftp/lftp-4.8.3.tar.gz

3.2解壓

tar xvf lftp-4.8.3.tar.gz

3.3生成Makefile

 

3.4安裝

 

 

未完待續......

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM