Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis CI with C++14 and Linux

Similar: Travis CI with Clang 3.4 and C++11

How does one get Travis CI to work with C++14?

Here is our current .travis.yml file:

language: cpp
compiler:
 - gcc
 - clang
os:
 - linux
 - osx
script:
    make main

Here is our makefile

# Factor Pro

# Macros
CXXFLAGS = -Os -std=c++14

# Rules
all::main

main: main.cpp
    g++ -o main $(CXXFLAGS) main.cpp

clean:
    rm -rf *.o main

It works on osx, but not linux.

like image 603
PyRulez Avatar asked Jan 31 '16 03:01

PyRulez


People also ask

Is Travis CI a CI tool?

Travis CI is a hosted continuous integration service used to build and test software projects hosted on GitHub and Bitbucket. Travis CI was the first CI service which provided services to open-source projects for free and continues to do so.

What is Travis CI used for?

As a continuous integration platform, Travis CI supports your development process by automatically building and testing code changes, providing immediate feedback on the success of the change. Travis CI can also automate other parts of your development process by managing deployments and notifications.

Which Travis CI infrastructure environment runs full virtual machines?

Our default infrastructure is an Ubuntu Linux ( os: linux ) virtual machine running on AMD64 architecture ( arch: amd64 ), on Google Compute Engine.


1 Answers

The default GCC and Clang versions are horribly outdated, and you'll need to install newer versions manually like this:

language: generic
os: osx
matrix:
  include:
    - os: linux
      env: COMPILER_NAME=gcc CXX=g++-5 CC=gcc-5
      addons:
        apt:
          packages:
            - g++-5
          sources: &sources
            - llvm-toolchain-precise-3.8
            - ubuntu-toolchain-r-test
    - os: linux
      env: COMPILER_NAME=clang CXX=clang++-3.8 CC=clang-3.8
      addons:
        apt:
          packages:
            - clang-3.8
          sources: *sources

You can install multiple versions of Clang and GCC like this.

Note: I'm using language: generic, because if language: cpp, TravisCI's horribly-outdated CC and CXX override per-cell exports and it's faster.

I also recommend you use

    $(CXX) -o main $(CXXFLAGS) main.cpp

Because the C++ compiler is almost never g++ in the real world.

like image 73
набиячлэвэли Avatar answered Oct 28 '22 21:10

набиячлэвэли