1) google之后,找到 这个 https://github.com/z24/pitv/tree/master/cross 的脚本,
觉得非常好。 于是准备用来进行编译
2) 安装交叉编译器
sudo apt-get install gcc-arm-linux-gnueabihfsudo apt-get install g++-arm-linux-gnueabihf
特别需要注意的是,g++一定需要安装。 之前由于没安装,出现了各种费解的错误,差点就放弃了
比如说 明明 expat编译的好好的,却在 configure aria2的时候,硬是找不到。
还有,在最后链接阶段, 出现了 undefined reference 错误
3)http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz 因为有墙,自动下载不了,需要另外FQ下载。
4)最后修正的编译脚本。
#!/bin/sh# This script downloads and builds a static aria2 binary for raspberry pi.# Copyright 2014 Youjie Zhou# All rights reserved.CWD=$(pwd)export ARCH=armexport NJOB=4export CPP="/usr/bin/arm-linux-gnueabihf-cpp"export CC="/usr/bin/arm-linux-gnueabihf-gcc"export CXX="/usr/bin/arm-linux-gnueabihf-g++"export TOOL_CC=${CC}export LD="/usr/bin/arm-linux-gnueabihf-ld"export AR="/usr/bin/arm-linux-gnueabihf-ar"export AS="/usr/bin/arm-linux-gnueabihf-as"export RANLIB="/usr/bin/arm-linux-gnueabihf-ranlib"# Local folder where we install built binaries and libraries.LOCAL_DIR=$(readlink -f ./local)mkdir -p ${LOCAL_DIR}# Cross-compiler tools. Latest version can be downloaded at:# github.com/raspberrypi/toolsTOOL_DIR=/usrTOOL_BIN_DIR=${TOOL_DIR}/binPATH=${TOOL_BIN_DIR}:$PATH# zlibrm -rf zlib-1.2.8#wget http://zlib.net/zlib-1.2.8.tar.gz ./tar xzf zlib*.tar.gzcd zlib*/prefix=${LOCAL_DIR} CC=${TOOL_CC} CFLAGS="-O4" ./configure --staticmake -j${NJOB}make installcd ${CWD}# expatrm -rf expat-2.1.0#wget http://downloads.sourceforge.net/expat/2.1.0/expat-2.1.0.tar.gz ./tar xzf expat*.tar.gzcd expat*/./configure \ --host=arm-linux-gnueabihf \ --build=${ARCH}-linux \ --enable-shared=no \ --enable-static=yes \ --prefix=${LOCAL_DIR}make -j${NJOB}make installcd ${CWD}# c-aresrm -rf c-ares-1.10.0#wget http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz ./tar xzf c-ares*.tar.gzcd c-ares*/./configure \ --host=arm-linux-gnueabihf \ --build=${ARCH}-linux \ --enable-shared=no \ --enable-static=yes \ --prefix=${LOCAL_DIR}make -j${NJOB}make installcd ${CWD}# aria2rm -rf aria2-1.18.10#wget http://downloads.sourceforge.net/aria2/aria2-1.18.10.tar.xz ./tar xJf aria2*.tar.xzcd aria2*/./configure \ --host=arm-linux-gnueabihf \ --build=${ARCH}-linux \ --disable-nls \ --disable-ssl \ --disable-epoll \ --without-gnutls \ --without-openssl \ --without-sqlite3 \ --without-libxml2 \ --with-libz --with-libz-prefix=${LOCAL_DIR} \ --with-libexpat --with-libexpat-prefix=${LOCAL_DIR} \ --with-libcares --with-libcares-prefix=${LOCAL_DIR} \ --prefix=${LOCAL_DIR} \ CXXFLAGS="-Os -g" \ CFLAGS="-Os -g" \ LDFLAGS="-L${LOCAL_DIR}/lib" \ PKG_CONFIG_LIBDIR="${LOCAL_DIR}/lib/pkgconfig" \ ARIA2_STATIC=yesmake -j${NJOB}make install