1) google之后,找到 這個 https://github.com/z24/pitv/tree/master/cross 的腳本,
覺得非常好。 於是准備用來進行編譯
2) 安裝交叉編譯器
sudo apt-get install gcc-arm-linux-gnueabihf sudo 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 因為有牆,自動下載不了,需要另外翻牆下載。
4)最后修正的編譯腳本。
#!/bin/sh # This script downloads and builds a static aria2 binary for raspberry pi. # Copyright 2014 Youjie Zhou <jmpopush@gmail.com> # All rights reserved. CWD=$(pwd) export ARCH=arm export NJOB=4 export 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/tools TOOL_DIR=/usr TOOL_BIN_DIR=${TOOL_DIR}/bin PATH=${TOOL_BIN_DIR}:$PATH # zlib rm -rf zlib-1.2.8 #wget http://zlib.net/zlib-1.2.8.tar.gz ./ tar xzf zlib*.tar.gz cd zlib*/ prefix=${LOCAL_DIR} CC=${TOOL_CC} CFLAGS="-O4" ./configure --static make -j${NJOB} make install cd ${CWD} # expat rm -rf expat-2.1.0 #wget http://downloads.sourceforge.net/expat/2.1.0/expat-2.1.0.tar.gz ./ tar xzf expat*.tar.gz cd expat*/ ./configure \ --host=arm-linux-gnueabihf \ --build=${ARCH}-linux \ --enable-shared=no \ --enable-static=yes \ --prefix=${LOCAL_DIR} make -j${NJOB} make install cd ${CWD} # c-ares rm -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.gz cd c-ares*/ ./configure \ --host=arm-linux-gnueabihf \ --build=${ARCH}-linux \ --enable-shared=no \ --enable-static=yes \ --prefix=${LOCAL_DIR} make -j${NJOB} make install cd ${CWD} # aria2 rm -rf aria2-1.18.10 #wget http://downloads.sourceforge.net/aria2/aria2-1.18.10.tar.xz ./ tar xJf aria2*.tar.xz cd 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=yes make -j${NJOB} make install