Travis CI 与 C++14 和 Linux
类似:Travis CI 与 Clang 3.4 和 C++11
如何让 Travis CI 与 C++14 一起工作?
How does one get Travis CI to work with C++14?
这是我们当前的 .travis.yml
文件:
Here is our current .travis.yml
file:
language: cpp
compiler:
- gcc
- clang
os:
- linux
- osx
script:
make main
这是我们的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
它适用于 osx
,但不适用于 linux
.
It works on osx
, but not linux
.
推荐答案
默认的 GCC 和 Clang 版本已经过时了,你需要像这样手动安装更新的版本:
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
您可以安装多个版本的 Clang 和 GCC,例如 this.
You can install multiple versions of Clang and GCC like this.
注意:我使用的是 language: generic
,因为如果 language: cpp
,TravisCI 的 CC
和 CXX 已经过时了
覆盖每个单元格的导出,它更快.
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.
我也推荐你使用
$(CXX) -o main $(CXXFLAGS) main.cpp
因为 C++ 编译器在现实世界中几乎从不 g++
.
Because the C++ compiler is almost never g++
in the real world.
相关文章