Skip to content

Instantly share code, notes, and snippets.

@moalex
Last active January 22, 2024 18:09
Show Gist options
  • Save moalex/f2687a6c0071c5e0440384294490f3fd to your computer and use it in GitHub Desktop.
Save moalex/f2687a6c0071c5e0440384294490f3fd to your computer and use it in GitHub Desktop.

How to build

sudo apt-get update && sudo apt-get -y dist-upgrade && sudo apt-get -y install gcc libssl-dev nettle-dev libgmp-dev libssh2-1-dev libc-ares-dev libxml2-dev zlib1g-dev libsqlite3-dev pkg-config libexpat1-dev libxml2-dev libcppunit-dev autoconf automake autotools-dev autopoint libtool; git clone https://github.com/aria2/aria2.git && cd aria2 && git checkout -b tags/release-1.36.0 release-1.36.0 && bash -c "autoreconf -i && ./configure" && make -j 2 && sudo make install

aria2 is primarily written in C++. Initially it was written based on C++98/C++03 standard features. We are now migrating aria2 to C++11 standard. The current source code requires C++11 aware compiler. Fo well-known compilers, such as g++ and clang, the -std=c++11 or -std=c++0x flag must be supported.

In order to build aria2 from the source package, you need following development packages (package name may vary depending on the distribution you use):

  • libgnutls-dev Required for HTTPS, BitTorrent, Checksum support
  • nettle-dev Required for BitTorrent, Checksum support
  • libgmp-dev Required for BitTorrent
  • libssh2-1-dev Required for SFTP support
  • libc-ares-dev Required for async DNS support
  • libxml2-dev Required for Metalink support
  • zlib1g-dev Required for gzip, deflate decoding support in HTTP
  • libsqlite3-dev Required for Firefox3/Chromium cookie support
  • pkg-config Required to detect installed libraries

You can use libgcrypt-dev instead of nettle-dev and libgmp-dev:

  • libgpg-error-dev Required for BitTorrent, Checksum support
  • libgcrypt-dev Required for BitTorrent, Checksum support

You can use libssl-dev instead of libgnutls-dev, nettle-dev, libgmp-dev, libgpg-error-dev and libgcrypt-dev:

  • libssl-dev Required for HTTPS, BitTorrent, Checksum support

You can use libexpat1-dev instead of libxml2-dev:

  • ``libexpat1-dev` Required for Metalink support

On Fedora you need the following packages: gcc, gcc-c++, kernel-devel, libgcrypt-devel, libxml2-devel, openssl-devel, gettext-devel, cppunit.

If you downloaded source code from git repository, you have to install following packages to get autoconf macros:

  • libxml2-dev
  • libcppunit-dev
  • autoconf
  • automake
  • autotools-dev
  • autopoint
  • libtool

And run following command to generate configure script and other files necessary to build the program:

autoreconf -i

Also you need Sphinx to build man page.

If you are building aria2 for Mac OS X, take a look at the make-release-os.mk GNU Make makefile.

The quickest way to build aria2 is first run configure script:

./configure

To build statically linked aria2, use ARIA2_STATIC=yes command-line option:

./configure ARIA2_STATIC=yes

After configuration is done, run make to compile the program:

make

See Cross-compiling Windows binary to create a Windows binary.

See Cross-compiling Android binary to create an Android binary.

The configure script checks available libraries and enables as many features as possible except for experimental features not enabled by default.

Since 1.1.0, aria2 checks the certificate of HTTPS servers by default. If you build with OpenSSL or the recent version of GnuTLS which has gnutls_certificate_set_x509_system_trust() function and the library is properly configured to locate the system-wide CA certificates store, aria2 will automatically load those certificates at the startup. If it is not the case, I recommend to supply the path to the CA bundle file. For example, in Debian the path to CA bundle file is /etc/ssl/certs/ca-certificates.crt (in ca-certificates package). This may vary depending on your distribution. You can give it to configure script using --with-ca-bundle option:

./configure --with-ca-bundle='/etc/ssl/certs/ca-certificates.crt'
make

Without --with-ca-bundle option, you will encounter the error when accessing HTTPS servers because the certificate cannot be verified without CA bundle. In such case, you can specify the CA bundle file using aria2's --ca-certificate option. If you don't have CA bundle file installed, then the last resort is disable the certificate validation using --check-certificate=false.

Using the native OSX (AppleTLS) and/or Windows (WinTLS) implementation will automatically use the system certificate store, so --with-ca-bundle is not necessary and will be ignored when using these implementations.

By default, the bash_completion file named aria2c is installed to the directory $prefix/share/doc/aria2/bash_completion. To change the install directory of the file, use --with-bashcompletiondir option.

After a make the executable is located at src/aria2c.

aria2 uses CppUnit for automated unit testing. To run the unit test:

make check

gistlog.co

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment