1

I'm working on an existing project locally. I am new to the project, so I am using the supplied make files as-is. I modified some code, ran make, and the build passed.

When I push the changes to github, the automated Travis CI build detected a compile error.

Searching for the error here on StackOverflow showed me that it is an error in pre-C++11, but not an error is C++11 and later.

This means that my local make must be compiling with the C++11 flag on, while the Travis CI build on the server is compiling without the flag.

Ideally I'd like my local build conditions to match the server build conditions so that I can detect any errors before pushing.

Where can I see the flags being passed to GCC for my local make operation, or is there some other way to explicitly disable the C++11 compilation flag?

smg
  • 1,133
  • 1
  • 11
  • 22
  • Check whether you have `CXXFLAGS` set anywhere. – juanchopanza May 07 '14 at 07:48
  • @juanchopanza I grepped for the flag locally, but don't see it being used anywhere. Is it possible that it's implicitly being passed?.. – smg May 07 '14 at 07:53
  • 1
    try `make VERBOSE=1` usually it helps ( if supported by your build script ) – user2485710 May 07 '14 at 07:54
  • How are the makefiles created? Where they hand-coded? Made by e.g. [CMake](http://www.cmake.org/) or similar tool? Don't you see the actual commands issued by `make` (and also the flags)? – Some programmer dude May 07 '14 at 07:55
  • 1
    You should be able to see the command line used to compile each file. So look at the output when you build your project and check which flags are used (e.g. if there is a -std=c++0x or similar) so you can verify that it really is a C++11 mode that causes the problem. Also CXXFLAGS might be taken from your shell environment variables, so check that. Otherwise, you need to read and understand how your Makefile compiles the source and which flags and variables it uses to do so, the author is free use anything, it doesn't have to be the CXXFLAGS variable. – nos May 07 '14 at 08:01
  • Have a look at [this question](http://stackoverflow.com/questions/5820303/how-do-i-force-make-gcc-to-show-me-the-commands) to see what commands are actually executed by make – lethal-guitar May 07 '14 at 08:14
  • What OS do you use, locally, and what does TravisCI use? Presumably the default flags on the compiler don't match (surely the makefile must be the same). – ams May 09 '14 at 10:28

1 Answers1

1

Say you have some all target, that is used to build the main stuff:

all: (some dependencies)
    (some commands)

To make sure at build-time what flags are used, you can add some dummy dependency:

all: (some dependencies) showflags
    (some commands)

showflags:
    @echo "CXXFLAGS=$(CXXFLAGS)"
    @echo "CPPFLAGS=$(CPPFLAGS)"

At least you will be able to see what options are used.

kebs
  • 6,387
  • 4
  • 41
  • 70