2
votes

I'm just getting started with using travis-CI, so I apologize if this is a silly or obvious question.

Following the instructions here:

I wrote the following travis.yml

language: cpp

dist: trusty

matrix:
  include:
    - os: linux
      compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env:
        - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
    - os: linux
      compiler: clang
      addons:
        apt:
          sources:
            - llvm-toolchain-trusty-5.0
          packages:
            - clang-5.0
      env:
        - MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"

before_install:
    - eval "${MATRIX_EVAL}"

script:
    - mkdir build
    - cd build
    - cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
    - cmake --build .
    - ctest

Which causes the following error in the clang build:

/home/travis/build/FrancoisChabot/abulafia/./include/abulafia/support/type_traits.h:20:12: error: no member named 'decay_t' in namespace 'std'; did you mean 'decay'?

/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:1725:11: note: 'decay' declared here

When compiling with the following command:

cd /home/travis/build/FrancoisChabot/abulafia/build/tests/char_set && /usr/bin/clang++-5.0 -Wall -pedantic -Wextra -std=c++17 -I/home/travis/build/FrancoisChabot/abulafia/./include -I/home/travis/build/FrancoisChabot/abulafia/googletest/googletest/include -o CMakeFiles/char_set_tests.dir/test_any.cpp.o -c

Which tells me it's loading gcc's libraries. Is there something I'm not understanding right here?

link to the full log If there is something important I ommited.

Thanks!

2

2 Answers

5
votes

Yes, this is a well-known issue with the travis-ci build environment. It is compiling and linking against the default ubuntu-trusty libstdc++, which is the gcc 4-series stdlib and not even C++11 conforming.

See an issue I opened a long time ago.

If you need a C++14 libstdc++ with travis-ci, you should use docker and make a more recent ubuntu image. That's the best workaround AFAIK.

1
votes

This can be fixed by installing g++7 alongside clang, to upgrade the standard library. The relevant matrix entry becomes:

matrix:
  include:
    - os: linux
      addons:
        apt:
          sources:
            - llvm-toolchain-trusty-5.0
            - ubuntu-toolchain-r-test
          packages:
            - clang-5.0
            - g++-7
      env: MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"

Replacing this into the OP's yaml should do the trick. Note: compiler: clang was in excess – its effects get overridden by the eval "${MATRIX_EVAL}" trick.