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?
One can also use clang with Microsoft Visual Studio C and C++ libraries.
TL;DR: Clang is highly compatible to GCC - just give it a go. In most cases, Clang could be used as a GCC drop in replacement ( clang and clang++ are "GCC compatible drivers").
Apple uses a specialized version of GCC 4.0 and 4.2 in Leopard's Xcode 3.1 that supports compiling Objective-C/C/C++ code to both PowerPC and Intel targets on the desktop and uses GCC 4.0 to target ARM development on the iPhone.
Clang is an LLVM native C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles (e.g. about 3x faster than GCC when compiling Objective-C code in a debug configuration), extremely useful error and warning messages and to provide a platform for building great source level tools.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With