4

This project work fine on my local Ubuntu 12.04 and Mac OSX 10.10 (with fink python) machines. I can't seem to figure out how to configure the .travis.yml to get the .cpp files to build with g++-4.8 (4.9 or 5.x) would be fine too.

Project: https://github.com/schwehr/libais

My most recent failed attempt:

language: python

python:
  - "2.7"
  - "3.4"

before_install:
  - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
  - sudo apt-get update -qq
  - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi

install:
  - sudo apt-get install -qq gcc-4.8 g++-4.8
  - python setup.py install

script:
  - python setup.py test 

Gives:

gcc -pthread -fno-strict-aliasing -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/python/2.7.9/include/python2.7 -c src/libais/ais_py.cpp -o build/temp.linux-x86_64-2.7/src/libais/ais_py.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
cc1plus: error: unrecognized command line option ‘-std=c++11’

The key portion of my setup.py:

EXTRA_COMPILE_ARGS = []
if sys.platform in ('darwin', 'linux', 'linux2'):
    EXTRA_COMPILE_ARGS = ['-std=c++11']

AIS_MODULE = Extension(
    '_ais',
    extra_compile_args=EXTRA_COMPILE_ARGS,
Kurt Schwehr
  • 2,638
  • 3
  • 24
  • 41
  • 1
    Can you confirm the version of g++ on Travis CI? You could do this by adding a line in `before_install` that prints the version e.g. `g++ --version`. In versions pre-G++ 4.7, you'll have to use `-std=c++0x`, for more recent versions you can use `-std=c++11`. Reference: http://stackoverflow.com/a/14674646/213272 – Dominic Jodoin May 21 '15 at 16:50

1 Answers1

3

Thanks Dominic. I tried printing things and that was helpful. That got me thinking that I could just get explicit and force python to use the correct compiler. That makes it easier to see what is happening.

install:
  - sudo apt-get install -qq gcc-4.8 g++-4.8
  - CC=g++-4.8 python setup.py install

Which works.

Kurt Schwehr
  • 2,638
  • 3
  • 24
  • 41
  • A container based solution without sudo: https://github.com/schwehr/generic-sensor-format/commit/9e7df49ed2008a266934885ad4c17e347a4bf46f – Kurt Schwehr Jul 14 '15 at 14:48