简体   繁体   English

Travis CI与C ++ 14和Linux

[英]Travis CI with C++14 and Linux

Similar: Travis CI with Clang 3.4 and C++11 类似: Travis CI与Clang 3.4和C ++ 11

How does one get Travis CI to work with C++14? 如何让Travis CI与C ++ 14一起工作?

Here is our current .travis.yml file: 这是我们当前的.travis.yml文件:

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

Here is our makefile 这是我们的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 . 它适用于osx ,但不适用于linux

The default GCC and Clang versions are horribly outdated, and you'll need to install newer versions manually like this: 默认的GCC和Clang版本非常过时,您需要手动安装更新版本,如下所示:

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 . 您可以像这样安装多个版本的Clang和GCC。

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. 注意:我正在使用language: generic ,因为如果language: cpp ,TravisCI可怕的过时的CCCXX会覆盖每个单元格的出口并且速度更快。

I also recommend you use 我也建议你使用

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

Because the C++ compiler is almost never g++ in the real world. 因为C ++编译器在现实世界中几乎不是g++

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM