ubuntu10.04 交叉编译 aria2 总结

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 因为有墙,自动下载不了,需要另外FQ下载。

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

 

posted @ 2015-11-28 19:07  johnsonshu  阅读(2297)  评论(0编辑  收藏  举报