Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
750 views
in Technique[技术] by (71.8m points)

c++ - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...