Travis fails first build in matrix - c++

I have started building my project on travis and, after managing to build with one compiler, I decided to cover more and use matrix builds to build with a variety of compilers on Linux. I have managed to get a configuration that builds successfully for all entries except the first one. The exact error I get is:
$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install g++-5 libncurses5-dev
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package g++-5
E: Couldn't find any package by regex 'g++-5'
apt-get.diagnostics
apt-get install failed
My travis configuration looks like:
sudo: false
language: generic
matrix:
include:
- os: linux
env: COMPILER_NAME=g++ CXX=g++-5 CC=gcc-5
addons:
apt:
source: &sources
- llvm-toolchain-precise-3.8
- llvm-toolchain-precise-3.7
- llvm-toolchain-precise-3.6
- ubuntu-toolchain-r-test
packages:
- g++-5
- libncurses5-dev
- os: linux
env: COMPILER_NAME=clang++ CXX=clang++-3.8 CC=clang-3.8
addons:
apt:
sources: *sources
packages:
- clang-3.8
- libncurses5-dev
- os: linux
env: COMPILER_NAME=clang CXX=clang++-3.7 CC=clang-3.7
addons:
apt:
sources: *sources
packages:
- clang-3.7
- libncurses5-dev
- os: linux
env: COMPILER_NAME=clang CXX=clang++-3.6 CC=clang-3.6
addons:
apt:
sources: *sources
packages:
- clang-3.6
- libncurses5-dev
before_script:
- mkdir -p build
- cd build
script:
- cmake -DCMAKE_BUILD_TYPE=DEBUG .. && make && make runtests
At this point I feel like I am missing something obvious. I cannot find any solution to this problem (or simply don't know how to search for it effectively).
I feel I should mention that if I swap the gcc section with one of the clang sections that the clang section will fail and the gcc section will pass.
If I can provide anymore useful information then let me know! Thanks in advance for your help.

Simply misspelled sources in the first entry. Corrected that and removed the back referencing and everything is working.

Related

Specifying compiler versions in travis for cmake builds

The travis Building a C++ Project documentation shows how to specify gcc and clang compiler versions in build matrices. However, it does not show how to build projects with those compilers using cmake.
I amended the .travis.yml file here to specify gcc 9 and clang 8 as per the travis documentation, i.e.:
matrix:
include:
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
- compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-bionic-8
packages:
- clang-8
- libstdc++-8-dev
env:
- MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
before_install:
- eval "${MATRIX_EVAL}"
- pip install --user cpp-coveralls
...
script:
- mkdir _builds
- cd _builds
- cmake -DVIA_HTTPLIB_UNIT_TESTS=ON -DVIA_HTTPLIB_COVERAGE=ON ${CMAKE_OPTIONS} ..
- make
- ./via-httplib_test
But is caused build errors when running cmake, e.g.:
$ cmake -DVIA_HTTPLIB_UNIT_TESTS=ON -DVIA_HTTPLIB_COVERAGE=ON ${CMAKE_OPTIONS} ..
CMake Error at /usr/local/cmake-3.12.4/share/cmake-3.12/Modules/CMakeDetermineCCompiler.cmake:48 (message):
Could not find compiler set in environment variable CC:
gcc-9.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/home/travis/build/kenba/via-httplib/_builds/CMakeFiles/CMakeOutput.log".
The command "cmake -DVIA_HTTPLIB_UNIT_TESTS=ON -DVIA_HTTPLIB_COVERAGE=ON ${CMAKE_OPTIONS} .." exited with 1.
I tried fixing the errors by specifying CMAKE_C_COMPILER and CMAKE_CXX_COMPILER for cmake, but I could not get it to work.
However, it builds correctly with:
env:
- MATRIX_EVAL="CC=gcc && CXX=g++"
...
env:
- MATRIX_EVAL="CC=clang && CXX=clang++"
but builds with the default bionic gcc and clang compilers, i.e.: GCC 7.4.0 and Clang 7, not GCC 9 and Clang 8.
How to write a .travis.yml file so that cmake can find and use
the compiler versions specified in a matrix?
Perhaps it was a Travis issue? Simply adding the g++-9 package and changing the variable to MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" results in a successful compilation of your project with GCC 9.3.0
This is a minimal example that I use for building my project:
language: cpp
matrix:
include:
- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- clang-8
env:
- MATRIX_EVAL="CC=clang-8 CXX=clang++-8"
- os: linux
addons:
apt:
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
packages:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9 CXX=g++-9"
before_install:
- eval "${MATRIX_EVAL}"
script:
- cmake .
- make

Travis CI C++ Build succeed but travis exited with 1 and doesn't passes the test

I am trying to integrate my project with Travis CI, and when i build it everything seems to be ok, but the built is still failing and I get the message
Done. Your build exited with 1. but the CMake build give me message The command "cmake --build . -- -j2" exited with 0.
Here is my outupt of the build in travis-ci :
https://travis-ci.org/stelro/Fission-Engine
Here is the CMakeList.txt of the project:
https://github.com/stelro/Fission-Engine/blob/EntityComponentSystem/CMakeLists.txt
And here is the travis.yml:
https://github.com/stelro/Fission-Engine/blob/EntityComponentSystem/.travis.yml
Can someone help me and explaine me why I cannot pass the travis-ci build?
You are trying to install gcc-6 and set up links manually. Operations such as
ln -s /usr/bin/gcc-6 /usr/local/bin/gcc
require sudo which is disabled in your .travis.yml file. The better approach would be to specify gcc-6 as part of your build matrix:
matrix:
include:
# g++ builds
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
env:
- COMPILER="g++-6"

Travis CI seems to be reading from the wrong stdlib

I'm just getting started with using travis-CI, so I apologize if this is a silly or obvious question.
Following the instructions here:
I wrote the following travis.yml
language: cpp
dist: trusty
matrix:
include:
- os: linux
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- os: linux
compiler: clang
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
env:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
before_install:
- eval "${MATRIX_EVAL}"
script:
- mkdir build
- cd build
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
- cmake --build .
- ctest
Which causes the following error in the clang build:
/home/travis/build/path_to_project/./include/abulafia/support/type_traits.h:20:12:
error: no member named 'decay_t' in namespace 'std'; did you mean
'decay'?
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:1725:11:
note: 'decay' declared here
When compiling with the following command:
cd /home/travis/build/path_to_project/build/tests/char_set && /usr/bin/clang++-5.0 -Wall -pedantic -Wextra -std=c++17 -I/home/travis/build/path_to_project/./include -I/home/travis/build/path_to_project/googletest/googletest/include -o CMakeFiles/char_set_tests.dir/test_any.cpp.o -c
Which tells me it's loading gcc's libraries. Is there something I'm not understanding right here?
Thanks!
Yes, this is a well-known issue with the travis-ci build environment. It is compiling and linking against the default ubuntu-trusty libstdc++, which is the gcc 4-series stdlib and not even C++11 conforming.
See an issue I opened a long time ago.
If you need a C++14 libstdc++ with travis-ci, you should use docker and make a more recent ubuntu image. That's the best workaround AFAIK.
This can be fixed by installing g++7 alongside clang, to upgrade the standard library. The relevant matrix entry becomes:
matrix:
include:
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
- ubuntu-toolchain-r-test
packages:
- clang-5.0
- g++-7
env: MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
Replacing this into the OP's yaml should do the trick. Note: compiler: clang was in excess – its effects get overridden by the eval "${MATRIX_EVAL}" trick.

using different libc++ versions on travis for clang

Travis uses Ubuntu Trusty and the default libc++ version there is svn199600.
However I would like to test with different (newer) versions as I already do with different clang versions.
My current .travis.yml looks as follows:
language: generic
dist: trusty
sudo: required
matrix:
include:
- env: CXX=g++-7 CC=gcc-7
addons:
apt:
packages:
- g++-7
sources: &sources
- ubuntu-toolchain-r-test
- llvm-toolchain-precise
- llvm-toolchain-precise-3.9
- llvm-toolchain-precise-3.8
- llvm-toolchain-precise-3.7
- llvm-toolchain-precise-3.6
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main'
key_url: 'http://apt.llvm.org/llvm-snapshot.gpg.key'
- env: CXX=g++-6 CC=gcc-6
addons:
apt:
packages:
- g++-6
sources: *sources
- env: CXX=g++-5 CC=gcc-5
addons:
apt:
packages:
- g++-5
sources: *sources
- env: CXX=g++-4.9 CC=gcc-4.9
addons:
apt:
packages:
- g++-4.9
sources: *sources
- env: CXX=clang++-4.0 CC=clang-4.0
addons:
apt:
packages:
- clang-4.0
- libc++-dev
sources: *sources
- env: CXX=clang++-3.9 CC=clang-3.9
addons:
apt:
packages:
- clang-3.9
- libc++-dev
sources: *sources
- env: CXX=clang++-3.8 CC=clang-3.8
addons:
apt:
packages:
- clang-3.8
- libc++-dev
sources: *sources
- env: CXX=clang++-3.7 CC=clang-3.7
addons:
apt:
packages:
- clang-3.7
- libc++-dev
sources: *sources
- env: CXX=clang++-3.6 CC=clang-3.6
addons:
apt:
packages:
- clang-3.6
- libc++-dev
sources: *sources
script:
- ./build_and_test.sh
before_install:
- ./before_install.sh
Replacing libc++-dev with libc++-dev-3.9 for example does not help (still uses old library version), even when adding the following line:
- sourceline: 'deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'
I also attempted to add the following to my before_install.sh without success (also still old library):
sudo apt-add-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.9 main"
sudo apt-get update
sudo apt-get install -y libc++-dev libc++-helpers libc++1 libc++abi-dev lldb-3.9
How is it done correctly without building from source?
It looks like it is not possible to do it without building from source. The range-v3 library uses a script doing exactly this.
I adjusted my travis.yml to use it too:
language: generic
dist: trusty
sudo: required
matrix:
include:
- os: linux
compiler: gcc
env: GCC_VERSION=7
- CC=gcc-7
- CXX=g++-7
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7']
- os: linux
compiler: gcc
env: GCC_VERSION=6
- CC=gcc-6
- CXX=g++-6
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6']
- os: linux
compiler: gcc
env: GCC_VERSION=5
- CC=gcc-5
- CXX=g++-5
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
- os: linux
compiler: clang
env: CLANG_VERSION=5.0 LIBCXX=On
- CC=clang-5.0
- CXX=clang++-5.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['clang-5.0', 'g++-6']
- os: linux
compiler: clang
env: CLANG_VERSION=4.0 LIBCXX=On
- CC=clang-4.0
- CXX=clang++-4.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
packages: ['clang-4.0', 'g++-6']
- os: linux
compiler: clang
env: CLANG_VERSION=3.9 LIBCXX=On
- CC=clang-3.9
- CXX=clang++-3.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.9']
packages: ['clang-3.9', 'g++-6']
- os: linux
compiler: clang
env: CLANG_VERSION=3.8 LIBCXX=On
- CC=clang-3.8
- CXX=clang++-3.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.8']
packages: ['clang-3.8', 'g++-6']
before_install:
- wget https://raw.githubusercontent.com/onqtam/doctest/master/doctest/doctest.h
- sudo mv ./doctest.h /usr/local/include/doctest.h
- |
if [ -n "$GCC_VERSION" ]; then
export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"
fi
if [ -n "$CLANG_VERSION" ]; then
export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"
fi
if [ "$LIBCXX" == "On" ]; then
sudo apt-get purge cmake
sudo apt-get install cmake3
cmake --version
sudo CXX="$CXX" CC="$CC"
sudo ./cmake/install_libcxx.sh
export CXXFLAGS="-stdlib=libc++"
fi
install:
- mkdir -p build && cd build
- cmake .. -DUNITTEST=ON
script:
- which $CXX
- $CXX --version
- cmake --build . --target unittest --config Release -- -j4

Travis-Ci Install and run CxxTest

I am trying to add Travis-Ci support for my open source project hosted on Github
Problem appears when CMake tries to find CxxTest. Travis-Ci runs on old Ubuntu version, in which CxxTest is not trusted. I achieved some results. At this state CxxTest installs fine, but CMake is unable to find cxxtestgen.
Question: How do I correctly install and use CxxTest in Travis-Ci ?
Build log on Travis
Travis.yml
language: cpp
compiler:
- gcc
before_install:
- lsb_release -c
- lsb_release -r
- sudo apt-add-repository 'deb http://archive.ubuntu.com/ubuntu vivid main universe multiverse restricted'
- sudo apt-add-repository 'deb http://archive.ubuntu.com/ubuntu trusty main universe multiverse restricted'
- sudo apt-key update
- sudo apt-get -y update
install:
- sudo apt-get --no-install-recommends -y install cxxtest;
- sudo find / -type f -name "cxxtestgen*"
- sudo ln /usr/share/cxxtest/cxxtest/cxxtestgen.py /usr/bin/cxxtestgen.py
- sudo find / -type f -name "cxxtestgen*"
- echo $PATH
before_script:
- cmake .
script: make
CMake log
$ cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
Could NOT find CxxTest (missing: CXXTEST_PERL_TESTGEN_EXECUTABLE)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindCxxTest.cmake:179 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
test/CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
The command "cmake ." failed and exited with 1 during .
Your build has been stopped.
I found answer by myself.
language: cpp
compiler:
- gcc
cache:
apt: true
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55/cmake-3.x
packages:
- gcc-6
- g++-6
- libboost-dev
- gcc-multilib
- gcc-6-multilib
- g++-multilib
- g++-6-multilib
- libc6-dev-i386
- libc6-i386
- cxxtest
- cmake
before_install:
- echo `getconf _NPROCESSORS_ONLN`
- lsb_release -c
- lsb_release -r
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-6" CC="gcc-6"; fi
before_script:
- cmake --version
- cmake .
script:
- make -j$((2 * `getconf _NPROCESSORS_ONLN`))
sudo: false
dist: trusty