Check out the latest superpixel benchmark — Superpixel Benchmark (2016) — and let me know your opinion! @david_stutz


Running OpenCV and Google GLog with CMake on Travis CI

Running C++ projects on Travis CI may be challenging depending on the libraries used. Here I briefly describe how to run OpenCV and Google GLog on Travis CI.

After successfully running some of my JavaScript projects on Travis CI, my C++ projects are next. While some libraries like OpenCV can be easily installed through apt-get, others like Google GLog need to be built manually. This article gives a brief example of how to link against OpenCV and Google GLog on Travis CI.

The project can be found on GitHub - in particular, here is the corresponding .travis.yml.

Running OpenCV on Travis

Using OpenCV on Travis, similar to many other libraries, can be accomplished through:

sudo apt-get install libopencv-dev

Other useful libraries:

sudo apt-get install libboost-all-dev
sudo apt-get install libeigen3-dev

Running Google GLog on Travis

Although Google GLog can be installed through sudo apt-get install libgoogle-glog-dev on recent versions of Ubuntu, this is not necessarily possible on Travis. However, Google GLog can be built on-the-fly using:

git clone https://github.com/davidstutz/glog
cd glog
git reset --hard 0b0b022
cd ..

This will install glog into the directory glog within the project's root directory. The hard reset is responsible for checking out version 0.3.3 of Google GLog. This is motivated by some issues with the latest version (see here).

When using CMake, the local Google GLog installation can easily be found using the following CMake script:

# - Try to find Glog
# The following variables are optionally searched for defaults
#  GLOG_ROOT_DIR:            Base directory where all GLOG components are found
# The following are set after configuration is done: 


set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog")

find_path(GLOG_INCLUDE_DIR glog/logging.h

find_library(GLOG_LIBRARY glog libglog

find_package_handle_standard_args(GLOG DEFAULT_MSG


When the script is saved to cmake/FindGLog.cmake, the CMakeLists.txt in the project's root needs to contain:


Google GLog can then be used using the variables GLOG_INCLUDE_DIRS and GLOG_LIBRARIES.

C++11 and C++14 on Travis

For using C++11 or C++14 features on Travis, for example using -std=c++11 for gcc, the Ubuntu 14.04 (Trusty) beta can be used:

sudo: required
dist: trusty

See here for details.

Putting it All Together

The full .travis.yml:

language: cpp

# For Ubuntu 14.04 C++11/15 support ...
sudo: required
dist: trusty

    - gcc

    - sudo apt-get install build-essential
    - sudo apt-get install cmake
    - sudo apt-get install libboost-all-dev
    - sudo apt-get install libopencv-dev
    - sudo apt-get install libeigen3-dev
    # Glog through apt-get does not work ...
    - git clone https://github.com/davidstutz/glog
    - cd glog
    - git reset --hard 0b0b022
    - ./configure
    - make
    - cd ..
    - mkdir build
    - cd build
    - cmake .. -DGLOG_ROOT_DIR=../glog

script: make 

What is your opinion on this article? Did you find it interesting or useful? Let me know your thoughts in the comments below or get in touch with me:


  • Carlos Gomes Martinho

    Hi David, could you explain why: “… on recent versions of Ubuntu, this is not necessarily possible on Travis.”
    My project is also failing on travis because of glog

    • davidstutz

      At the point of writing – when I remember correctly – this was due to the fact that Travis’ Ubuntu Trusty was (or still is) in beta, and it simply did not work for me. In addition, I needed to use specifically version 0.3.3 and manually building was simply easier ;)