我的c++应用程序无法在travis-ci中成功通过
Cannot make a successful pass in travis-ci for my C++ app
我正在做这个项目,它在我的桌面使用g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
和cmake version 2.8.12.2
编译得很好。
我是一个新的旅行-ci的东西,我写了一个.travis.yml
脚本如下
language: cpp
compiler:
- g++
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- libboost-all-dev
- cmake
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8 -std=c++11 -I/usr/include/boost -DENABLE_REINFORCEMENT_LEARNING" CC="gcc-4.8"; fi
before_script:
- mkdir build
- cd build
- cmake ..
script: make
我的项目有boost
库依赖。
我的问题是travis-ci指示编译器错误在我的timer
变量。
#include "stdafx.hpp"
#include <list>
#include <mutex>
#include <atomic>
#include <thread>
#include <fstream>
#include <sstream>
#include <signal.h>
#include <iostream>
#include <functional>
#include "timer.hpp"
#include "configs.hpp"
#include "incurses.hpp"
#include "quadrotor.hpp"
#include "main.helper.hpp"
#include "main.output.hpp"
#ifdef ENABLE_REINFORCEMENT_LEARNING
# include "RLearner.Sarsa.hpp"
#endif
volatile bool
sig_ctrl_c = false;
std::mutex log_lock;
> timer screener; <
// /home/travis/build/noise2/quadrotor-sim/main.cpp:27:1: error: ‘timer’ does not name a type
// timer screener;
scalar iter_simulation = 0;
const size_t max_iter_simulation = 1e+5;
您可以在这里看到travis-ci结果。
<标题> 30多个1)当我在桌面上成功编译时,为什么这是一个错误?[我。E,我做错了什么?]
2)如何让我的项目通过考试?
编辑
标题>请注意,
timer
类已经包含在内。
感谢@nfranklin我已经注意到什么是问题。为了解决这个问题,我不得不安装一个最新的boost版本,我想出了以下travis.yml
脚本。
language: cpp
compiler:
- g++
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- boost-latest
packages:
- gcc-4.8
- g++-4.8
- libboost1.55-all-dev
- cmake
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8 -std=c++11 -DENABLE_REINFORCEMENT_LEARNING" CC="gcc-4.8"; fi
before_script:
- mkdir build
- cd build
- cmake ..
script: make
现在一切都好了
我认为问题在于您的travis-ci配置文件中的以下步骤:
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8 -std=c++11 -I/usr/include/boost -DENABLE_REINFORCEMENT_LEARNING" CC="gcc-4.8"; fi
timer.hpp
被包括在boost(即boost/timer.hpp)中,因为-I/usr/include/boost
而不是你写的timer.hpp
。
您可以从该步骤中删除-I/usr/include/boost
。/usr/include
是由gcc自动搜索头文件的,所以你所包含的boost头文件(例如#include)将会被找到。
相关文章:
- C++ MFC Libraries in Travis CI
- 仅在使用 gradle 在 Travis CI 上编译时才"multiple definition" googletest 符号
- 使用 CMake C++17 项目设置 Travis CI
- C++ Cmake没有在Travis CI服务器上设置编译器语言标准
- Travis-CI Complex Makefile fails
- Travis CI 中奇怪的编译器错误不会在本地计算机上发生
- Travis CI 找不到头文件
- 如何使用"trusty"映像在本地执行C++程序的Travis CI?
- QT QOverload没有在Travis CI上声明在这个范围内
- Travis-Ci 安装并运行 CxxTest
- Travis CI似乎是从错误的Stdlib读书
- 在 Travis CI 上运行 C++ 测试时出现问题.Cmake 配置.如何在特拉维斯 ci 上运行测试套件?
- Travis CI:Clang在应推导移动构造函数时推论复制构造函数
- Travis CI with Clang 3.4 and C++11
- g++ 5.4.0 的 asan 不适用于 travis CI
- 是否有C 中使用OpenCV和Travis CI的示例项目
- 使用Travis CI编译c++项目
- Travis CI with C++14 and Linux
- 使用cppunit与travis-ci.org进行c++集成
- 我的c++应用程序无法在travis-ci中成功通过