How to use latest boost version in Travis CI?

Viewed 2808

I tried to install boost 1.64 in Travis CI environment in several way. But none of them was succeeded. In my first naive attempt I just added following line in travis script:

install:
  - sudo apt-get install libboost1.64-all-dev

The result was error message: cannot find package libboost1.64-all-dev

In second attempt I specified repository with necessary boost version.

before_install:
  - sudo add-apt-repository -y ppa:nschloe/boost-nightly
  - sudo apt-get update -qq
install:
  - sudo apt-get install libboost-all-dev
  # - sudo apt-get install libboost1.64-all-dev (also tried)

In the first case default boost version (1.54) was installed. In second case result was same error message: cannot find package libboost1.64-all-dev

In third attempt I manually typed instructions to install boost:

install:
  - sudo wget -O boost_1_64_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz/download
  - sudo tar xzvf boost_1_64_0.tar.gz
  - cd boost_1_64_0/
  - sudo ./bootstrap.sh --prefix=/usr/local
  - sudo ./b2
  - sudo ./b2 install 

As result my script took more than 30 min then was terminated. Is any simple (or just working) way to install other than default boost version to Travis CI?

3 Answers

Precompiled Boost

Here are the steps I followed to get this to work:

  1. Search on launchpad until I found a recent boost package build for the trusty environment. That was non trivial, but there is a currently maintained ppa from mhier called libboost-latest

  2. I found configuring the .travis.yml correctly to use the ppa nontrivial, so I present a working snippet below which I hope will help anyone else struggling with the same problem.

The following works for clang and gcc:

language: cpp
dist: trusty
sudo: false
os: linux

matrix:
  include:
    - env: COMPILER=g++-6 BUILD=Debug STANDARD=14
      compiler: gcc
      addons:
        apt:
          update: true
          sources:
            - sourceline: 'ppa:mhier/libboost-latest'
            - ubuntu-toolchain-r-test
          packages:
            - g++-6
            - boost1.67
    - env: COMPILER=g++-6 BUILD=Release STANDARD=14
      compiler: gcc
      addons:
        apt:
          update: true
          sources:
            - sourceline: 'ppa:mhier/libboost-latest'
            - ubuntu-toolchain-r-test
          packages:
            - g++-6
            - boost1.67
# the rest of your yaml file...

Hopefully mhier will keep this ppa running for a while, otherwise you'll have to go through step 1, or provide your own ppa. As the boost version numbers progress the package number will change, so check the ppa page to keep the package name up to date.

A complete working example can be found at the monstar github project.

Compiling boost from source You can also compile boost from source within your travis build, although you run the risk of timing out. The instruction for this are found in item 12 of boost's best practice handbook

Related