Aria2 is a command-line download utility. It can be used to download files quickly from http(s), ftp, bittorrent, magnet and metalink locations. I prefer this handy tool over other programs, such as Free Download Manager and Frostwire because it's lean, fast and full of features. It took me a couple of days to compile Aria2 with all the features available. The following step-by-step guide will help you build your own aria2 program (aria2c.exe) the way I did.
- Install MinGW
Follow one of the following guides to install MingW:
- POSIX Threads
Download the source for Pthreads library (pthreads-w32-2-9-1-release.tar.gz) and compile it like this:
make clean GC-static
cp pthread.h semaphore.h sched.h /mingw/include/
cp libpthreadGC2.a /mingw/lib/libpthread.a - zlib
Zlib is needed by the OpenSSL library below. Download the zlib source and compile it like this:
make -f win32/Makefile.gcc
make -f win32/Makefile.gcc install BINARY_PATH=/mingw/bin INCLUDE_PATH=/mingw/include LIBRARY_PATH=/mingw/lib - OpenSSL
Aria2 requires either GnuTLS or OpenSSL for secure transfers. In this guide, OpenSSL is chosen over GnuTLS. Use 7-zip to unpack the tarball because it contains symbolic links.
./Configure -DHAVE_STRUCT_TIMESPEC -DPTW32_STATIC_LIB -L/mingw/lib -lz -lpthread -lws2_32 --prefix=/mingw threads zlib mingw
make
make install Expat
Aria2 can use either LibXML2 or Expat for XML parsing. In this guide, Expat will be used. Download the expat source and compile expat like this:
./configure --build=i686-w64-mingw32 --prefix=/mingw --disable-shared --enable-static
make
make installC-Ares
C-Ares is a C library that performs DNS requests and resolves DNS names asynchronously. Download the C-ares source from c-ares.haxx.se and unpack it. Then, compile C-Ares as follows:
./configure --build=i686-w64-mingw32 --prefix=/mingw --disable-shared CPPFLAGS='-I/mingw/include -DCARES_STATICLIB'
make
make installSQLite 3
Download the SQLite source (sqlite-amalgamation-3071300.zip) and build SQLite 3:
gcc -O2 -DNDEBUG=1 -DTHREADSAFE=1 -c *.c
ar ru /mingw/lib/libsqlite3.a sqlite3.o
cp -iv *.h /mingw/includeCreate sqlite3.pc and put it in /mingw/lib/pkgconfig.
prefix=/mingw
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: SQLite
Description: SQL database engine
Version: 3.5
Libs: -L${libdir} -lsqlite3
Cflags: -I${includedir}aria2c
Finally, we are ready to compile Aria2. Download the Aria2 source from aria2.sf.net and unpack the source. Then, configure aria2 as follows:
./configure --build=i686-w64-mingw32 --prefix=/mingw --enable-threads=posix --with-ca-bundle=ca-bundle.crt --disable-nls LIBS='-lpthread -lws2_32 -lcares -lz' CPPFLAGS='-DPTW32_STATIC_LIB -DCARES_STATICLIB'
Then, issue the following commands to compile Aria2:
make
make install- Optionally, strip and compress the executable aria2c.exe.
strip aria2c.exe
upx --best --strip-relocs=0 aria2c.exe
To download my Windows builds of aria2, go here.
Aria2c Usage
aria2c --file-allocation=prealloc ftp://192.168.1.64/pardus.iso
If aria2 aborts a download due to a connection error, you can resume the download any time using aria2c like this:
aria2c -c ftp://192.168.1.64/pardus.iso
To download files from URL's written in a file urls.txt
to a folder Downloads
, run aria2 as follows. The urls.txt should contain one download per line with URL's seperated by a tab:
aria2c -i urls.txt -d Downloads
Thanks for the detailed instructions!
ReplyDeleteHave you seen this error before?
In file included from SocketCore.cc:35:
SocketCore.h:363: error: expected ',' or '...' before 'struct'
SocketCore.cc: In function 'SOCKET aria2::bindTo(const char*, uint16_t, int, int, int, std::string&)':
Aria2 1.8.0, TDM-2 4.4.1
I have installed aria2c step by step as above, but I found an error in enable-bittorent and openssl for windows.
ReplyDeleteWhat is wrong? help me, please!
awaited an answer from you. thanks before .....