11

If cc configuration is set to use -Werror is there a way to override -Werror flag from the terminal when using make?

Nickolay Kondratyev
  • 4,959
  • 4
  • 25
  • 43
  • 3
    Pass `-Wno-error` afterward to the compiler, probably putting in `CFLAGS` in the makefile will do. – Daniel Fischer Aug 01 '12 at 00:35
  • 1
    See [Make: Override a flag](http://stackoverflow.com/a/17325955/14558) to do this in a Makefile instead of from the terminal. There’s a better answer in that case. – andrewdotn Jun 26 '13 at 16:49
  • 2
    Finally I resolved this issue by modifying source files to remove -Werror, using this command `find . -name Makefile -or -name '*m4' -exec sed -i s/-Werror//g {} \;` Be sure to make a backup before using as it may break things. You may have to adjust `find` to find files that contains make definitions. – NeDark Jul 31 '15 at 18:01

1 Answers1

17

You can set flags when invoking make:

CFLAGS=-Wno-error make
blahdiblah
  • 33,069
  • 21
  • 98
  • 152
  • 12
    This probably won't work. Most makefiles have a default setting of CFLAGS, something like `CFLAGS = -O2 -g` or something. In order to override that you have to pass the assignment on the command line not in the environment: run `make CFLAGS=-Wno-error` instead. – MadScientist Aug 02 '12 at 02:03
  • 3
    @MadScientist Good point, but if you pass the CFLAGS assignment as an argument to `make` it'll clobber whatever would've been set and potentially break the build entirely (unless only `-Werror` was set). If that's the case, then the best way is really via `./configure --extra-cflags` if available. – blahdiblah Aug 02 '12 at 18:59