dariush
dariush

Reputation: 3341

Cannot make a successful pass in travis-ci for my C++ app

I am working on this project an it compiles fine in my desktop using g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 and cmake version 2.8.12.2.

I am new in travis-ci thing, I have wrote a .travis.yml script as follow

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

My project has boost library dependency.
My problem is the travis-ci indicates compiler error in my timer variable.

#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;

You can see the travis-ci result here.

Quesions

1) Why on earth this is an error when I have a successful compile in my desktop? [i.e, what am i doing wrong?]
2) How to make my project pass the travis-ci?


Edit

Note that class timer has been included already.

Upvotes: 1

Views: 620

Answers (2)

dariush
dariush

Reputation: 3341

Thanks to @nfranklin I have noticed what was the problem. For what it worth to solve the problem I had to install one of the latest boost version, I came up with following travis.yml script.

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 

Now it is all good :)

Upvotes: 5

nfranklin
nfranklin

Reputation: 405

I think the problem lies within the following step in your travis-ci config file:

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 is being included from boost (i.e. boost/timer.hpp) due to -I/usr/include/boost instead ofthe timer.hpp that you wrote.

You can remove the -I/usr/include/boost from that step . /usr/include is automatically searched for headers by gcc and and so the boost headers that you include (e.g. #include ) will be found.

Upvotes: 0

Related Questions