安装x86_64编译环境
sudo apt update
sudo apt dist-upgrade
sudo apt-get install build-essential mingw-w64-x86-64-dev make binutils autoconf automake autotools-dev libtool pkg-config curl dpkg-dev autopoint libcppunit-dev libxml2-dev libgcrypt11-dev lzip libgnutls28-dev nettle-dev libgmp-dev libssh2-1-dev libc-ares-dev zlib1g-dev libsqlite3-dev git gcc g++ quilt gcc-mingw-w64-x86-64 wget g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64
安装依赖库
wget -c --no-check-certificate https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz
wget -c --no-check-certificate https://github.com/libexpat/libexpat/releases/download/R_2_2_5/expat-2.2.5.tar.bz2
wget -c --no-check-certificate https://www.sqlite.org/2018/sqlite-autoconf-3230100.tar.gz
wget -c --no-check-certificate http://zlib.net/zlib-1.2.11.tar.gz
wget -c --no-check-certificate https://c-ares.haxx.se/download/c-ares-1.13.0.tar.gz
wget -c --no-check-certificate https://www.libssh2.org/download/libssh2-1.8.0.tar.gz
GMP安装脚本
#! /bin/bash
set -e
HOST=x86_64-w64-mingw32
VERSION=6.1.2
wget -c -t5 --no-check-certificate https://gmplib.org/download/gmp/gmp-$VERSION.tar.lz
tar xf gmp-$VERSION.tar.lz && \
cd gmp-$VERSION && \
./configure \
--disable-shared \
--enable-static \
--prefix=/usr/$HOST \
--host=$HOST \
--disable-cxx \
--enable-fat \
CFLAGS="-mtune=generic -O2 -g0" && \
make -j$(nproc) && \
make install
expat脚本
#! /bin/bash
set -e
HOST=x86_64-w64-mingw32
VERSION=2.2.5
wget -c -t5 --no-check-certificate https://sourceforge.net/projects/expat/files/expat/2.2.5/expat-$VERSION.tar.bz2
tar xf expat-$VERSION.tar.bz2 && \
cd expat-$VERSION && \
./configure \
--disable-shared \
--enable-static \
--prefix=/usr/$HOST \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` && \
make -j$(nproc) && \
make install
sqlite3脚本
#! /bin/bash
set -e
HOST=x86_64-w64-mingw32
VERSION=3230100
wget -c -t5 --no-check-certificate https://www.sqlite.org/2018/sqlite-autoconf-$VERSION.tar.gz
tar xf sqlite-autoconf-$VERSION.tar.gz && \
cd sqlite-autoconf-$VERSION && \
./configure \
--disable-shared \
--enable-static \
--prefix=/usr/$HOST \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` && \
make -j$(nproc) && \
make install
zlib脚本
#! /bin/bash
set -e
HOST=x86_64-w64-mingw32
VERSION=1.2.11
wget -c -t5 --no-check-certificate http://zlib.net/zlib-$VERSION.tar.gz
tar xf zlib-$VERSION.tar.gz && \
cd zlib-$VERSION && \
CC=$HOST-gcc \
AR=$HOST-ar \
LD=$HOST-ld \
RANLIB=$HOST-ranlib \
STRIP=$HOST-strip \
./configure \
--prefix=/usr/$HOST \
--libdir=/usr/$HOST/lib \
--includedir=/usr/$HOST/include \
--static && \
make -j$(nproc) && \
make install
c-ares脚本
#! /bin/bash
set -e
HOST=x86_64-w64-mingw32
VERSION=1.13.0
wget -c -t5 --no-check-certificate https://c-ares.haxx.se/download/c-ares-$VERSION.tar.gz
tar xf c-ares-$VERSION.tar.gz && \
cd c-ares-$VERSION && \
./configure \
--disable-shared \
--enable-static \
--without-random \
--prefix=/usr/$HOST \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
LIBS="-lws2_32" && \
make -j$(nproc) && \
make install
libssh2 脚本
#! /bin/bash
set -e
HOST=x86_64-w64-mingw32
VERSION=1.8.0
wget -c -t5 --no-check-certificate https://www.libssh2.org/download/libssh2-$VERSION.tar.gz
tar xf libssh2-$VERSION.tar.gz && \
cd libssh2-$VERSION && \
./configure \
--disable-shared \
--enable-static \
--prefix=/usr/$HOST \
--host=$HOST \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
--without-openssl \
--with-wincng \
LIBS="-lws2_32" && \
make -j$(nproc) && \
make install
编译aria2
git clone https://github.com/aria2/aria2.git
修改下载线程,默认为16,修改为128,或者2048。在aria2/src/OptionHandlerFactory.cc中查找TEXT_MAX_CONNECTION_PER_SERVER,将下面的16修改为2048。
运行编译脚本
#!/bin/sh -e
set -e
HOST=x86_64-w64-mingw32
PREFIX=/usr/$HOST
cd aria2 && \
autoreconf -fiv && \
./configure \
--host=$HOST \
--prefix=$PREFIX \
--without-included-gettext \
--disable-nls \
--with-libcares \
--without-gnutls \
--without-openssl \
--with-sqlite3 \
--without-libxml2 \
--with-libexpat \
--with-libz \
--with-libgmp \
--with-libssh2 \
--without-libgcrypt \
--without-libnettle \
--with-cppunit-prefix=$PREFIX \
ARIA2_STATIC=yes \
CPPFLAGS="-I$PREFIX/include" \
LDFLAGS="-L$PREFIX/lib" \
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" && \
make -j$(nproc) && \
$HOST-strip src/aria2c.exe
在aria2/src中就能看到aria2c.exe,拷贝到windows下就行。