问题描述
类似:
如何让Travis CI与C ++ 14配合使用?
当前 .travis.yml
文件:
语言:cpp
编译器:
- gcc
- clang
os:
- linux
- osx
脚本:
make main
这是我们的 makefile
#Factor Pro
#Macros
CXXFLAGS = -Os -std = c ++ 14
$ b b#Rules
all :: main
main:main.cpp
g ++ -o main $(CXXFLAGS)main.cpp
clean:
rm -rf * .o main
它适用于 osx
,但不是 linux
。
默认的GCC和Clang版本已经过时,您需要手动安装新版本,如下所示:
language:generic
os:osx
matrix:
include:
- os:linux
env:COMPILER_NAME = gcc CXX = g ++ - 5 CC = gcc-5
addons :
apt:
软件包:
- g ++ - 5
来源:& 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:
package:
- clang-3.8
来源:* sources
您可以安装多个版本Clang和GCC喜欢。
注意:我使用 language:generic
,因为如果 language:cpp
,TravisCI的可怕的过时的 CC
和 CXX
替换每个单元格导出,速度更快。
也建议您使用
$(CXX)-o main $(CXXFLAGS)main.cpp
因为C ++编译器在现实世界中几乎从不 g ++
>
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
.
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.
这篇关于Travis CI与C ++ 14和Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!