Travis CI with C++14 and Linux(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.
这篇关于Travis CI 与 C++14 和 Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Travis CI 与 C++14 和 Linux


基础教程推荐
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 从 std::cin 读取密码 2021-01-01