Build Libcurl with TLS and Nghttp2 for AVS Device SDK


This document provides step-by-step instructions to build libcurl with mbed TLS and nghttp2 in *nix systems.

We recommend that you use separate directories to keep track of your optimized builds, especially if you use these libraries elsewhere. For example, if you are building the Alexa Voice Service (AVS) Device SDK on a Linux machine that you use daily, installing these optimized versions might break other operations. Therefore, this document assumes that the principle working directory is $WD.

Ubuntu

These instructions are verified for Ubuntu 16.04.

  1. Run the following commands to install CMake. You can skip this step if CMake is already installed.

    wget https://cmake.org/files/v3.8/cmake-3.8.0-rc1.tar.gz
    tar -xvf cmake-3.8.0-rc1.tar.gz
    cd cmake-3.8.0-rc1/`  
    ./bootstrap && make && sudo make install
    

    NOTE: If you encounter issues bootstrapping or finding the appropriate C/C++ compiler, use the following command: sudo apt-get install build-essential.

  2. Install the latest version of nghttp2 to your principle working directory $WD. Run these commands:

    NOTE: This example presumes you have downloaded v1.19.0. Make sure you adjust the commands below to match the version of nghttp2 you have downloaded.

    wget https://github.com/nghttp2/nghttp2/releases/download/v1.19.0/nghttp2-1.19.0.tar.gz 
    tar -xvf nghttp2-1.19.0.tar.gz
    cd nghttp2-1.19.0
    autoreconf -i  
    

    NOTE: You might need to run the following command to obtain the correct tools: sudo apt-get update && sudo apt-get install g++ make binutils autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev -y

    automake
    autoconf
    ./configure --prefix=$WD/nghttp2/
    make
    sudo make install  
    
  3. Install the latest version of mbed TLS to your principle working directory $WD. Run these commands:

    NOTE: This example presumes you have downloaded v2.4.0. Make sure you adjust the commands below to match the version of mbed TLS you have downloaded.

    wget https://tls.mbed.org/download/mbedtls-2.4.0-apache.tgz  
    tar -xvf mbedtls-2.4.0-apache.tgz  
    cd mbedtls-2.4.0/  
    
    cmake -DCMAKE_INSTALL_PREFIX=$WD/mbedtls/ -DUSE_SHARED_MBEDTLS_LIBRARY=On`  
    make
    sudo make install
    
  4. Install the latest version of libcurl (7.50.2 or later). Run these commands:

    NOTE: This example presumes you have downloaded v7.53.0. Make sure you adjust the following command to match the version of libcurl you have downloaded.

    wget https://curl.haxx.se/download/curl-7.53.0.tar.gz 
    tar -xvf curl-7.53.0.tar.gz 
    cd curl-7.53.0/  
    LIBS="-lpthread" LDFLAGS="-Wl,-R$WD/mbedtls/lib" ./configure --with-nghttp2=$WD/nghttp2/ --without-ssl --with-mbedtls=$WD/mbedtls --prefix=$WD/curl/  
    The configuration summary should be printed to your terminal. Make sure that SSL support (mbed TLS) and HTTP/2 support (nghttp2) are enabled  
    make
    sudo make install
    
  5. Build the SDK.

    1. Pull the latest version of the SDK. From your project directory run: git pull.
    2. Pass the recently built libcurl to the make process. Note: This assumes that the source code for the SDK is located in $ACSDK_SOURCE_DIR and the build directory is $ACSDK_BUILD_DIR.
    3. Change directories: cd $ACSDK_BUILD_DIR
    4. Then run these commands:

      cmake -DCURL_LIBRARY=$WD/curl/lib/libcurl.so -DCURL_INCLUDE_DIR=$WD/curl/include/ $ACSDK_SOURCE_DIR`  
      make  
      make test
      

      NOTE: If Doxygen isn't found, you must run the following command: sudo apt-get install doxygen

macOS

  1. Install Homebrew, if you haven't done so already.
  2. Install cURL with HTTP2 support: brew install curl --with-nghttp2
  3. Force cURL to explicitly link to the updated binary: brew link curl --force
  4. Close and reopen terminal.
  5. Confirm version and source with this command: brew info curl

Was this page helpful?

Last updated: Sep 28, 2022