Questions tagged [cflags]

CFLAGS are switches that can be passed to the C compiler while compiling software.

CFLAGS are switches that can be passed to the C compiler while compiling software. CFLAGS are normally used inside Makefiles to have the same set of flags for the compilation.

CFLAGS can also be provided from outside of the Makefile via environment variables.

75 questions
125
votes
6 answers

CFLAGS vs CPPFLAGS

I understand that CFLAGS (or CXXFLAGS for C++) are for the compiler, whereas CPPFLAGS is used by the preprocessor. But I still don't understand the difference. I need to specify an include path for a header file that is included with #include --…
EBM
  • 1,683
  • 5
  • 15
  • 13
112
votes
4 answers

Set CFLAGS and CXXFLAGS options using CMake

I just want to debug some code running on Linux and I need a debug build (-O0 -ggdb). So I added these things to my CMakeLists.txt file: set(CMAKE_BUILD_TYPE DEBUG) set(CMAKE_C_FLAGS "-O0 -ggdb") set(CMAKE_C_FLAGS_DEBUG "-O0…
majie
  • 1,449
  • 2
  • 11
  • 10
34
votes
2 answers

How to set variable according to gradle flavors

I want to pass a variable test that I set differently per flavor as a define to the NDK. But for some reason he always passes the value of the last flavor. Here is the build.gradle: apply plugin: 'com.android.library' def test android { …
Torge
  • 2,174
  • 1
  • 23
  • 33
9
votes
1 answer

how can I pass CFLAGS and CXXFLAGS to cmake without altering the CMakeLists.txt (through CLI perhaps?)

I cannot alter the CMakeLists.txt of the project I work on and the cmake toolchain file used in there only declares C and CXX FLAGS for release. So for debugging I need to force my own flags (namely to append -O0 -DDEBUG to the CFLAGS and…
nass
  • 1,453
  • 1
  • 23
  • 38
7
votes
1 answer

Unable to use cgo CFLAGS

I have manually cloned the go directory of tensorflow(a library I am working on ) in /home/arafat/go/src/github.com/tensorflow/tensorflow/tensorflow/contrib/go you can take a look here. I have made changes to lib.go as // #cgo LDFLAGS:…
ArafatK
  • 740
  • 6
  • 25
7
votes
4 answers

Do I need to pass CFLAGS explicitly to gcc?

I read a lot of tutorials about CFLAGS and also looked in the official docs. Everywhere they say CFLAGS is implicit but still pass it explicitly in their example makefile to the compiler: CFLAGS=-O2 gcc $(CFLAGS) -c foo.c -o foo.o So, what does the…
Foo Bar
  • 1,764
  • 4
  • 24
  • 43
6
votes
2 answers

How to override compile flags for a single package in nixos?

How can I override compile flags (as in CFLAGS) for a single package in NixOS/Nix environments? Here's what I've got by now: let optimizeForThisHost = pkg: pkgs.lib.overrideDerivation pkg (old: { exportOptimizations = '' …
musicmatze
  • 4,124
  • 7
  • 33
  • 48
5
votes
1 answer

Remove a flag from CFLAGS in FreeBSD makefile

In a GNU makefile, it is possible to use filter-out to remove a flag from CFLAG like this : CFLAGS:=$(filter-out -flag,$(CFLAGS)) However, I can't make it work with a FreeBSD makefile. Is filter-out supported by FreeBSD ? Otherwise, what can I do…
poloDD
  • 71
  • 6
5
votes
1 answer

What does the gcc warning "coverage_mismatch" mean?

Today I meet a Werror=Wcoverage_mismatch error when compiling some erlang/opt: beam/beam_emu.c: In function 'erts_current_reductions': beam/beam_emu.c:3150:1: error: the control flow of function…
Chen Li
  • 4,824
  • 3
  • 28
  • 55
5
votes
2 answers

Changing *FLAGS in configure.ac vs. caching with subprojects

Say I wish to add a specific flag to CFLAGS within my configure script, that should propagate to all subprojects' configure scripts: CFLAGS+=" -Dfoobar" export CFLAGS AC_CONFIG_SUBDIRS([sub]) This works when configure is invoked trivially. As soon…
Irfy
  • 9,323
  • 1
  • 45
  • 67
5
votes
2 answers

What does .rodata and -fPIC mean when compiling OpenSSL?

I am trying to compile openssl but encountering an error. The CFLAGS in use are: -O2 -fPIC -fno-strict-overflow Can someone explain to me please what is .rodata and what the following sentence means? /usr/bin/ld: libcrypto.a(wp_block.o): relocation…
shevy
  • 920
  • 1
  • 12
  • 18
4
votes
1 answer

Correctly building local python3, with bz2 support

I am trying to build a local version of python3 (specifically python3.7, but same issue with 3.6.6), but am running into problems with linking to some C libraries and/or headers (at least that is what I think the problem is). I am able to build…
djmac
  • 827
  • 5
  • 11
  • 27
3
votes
2 answers

Does gcc "-fvisibility=hidden" hurt when applied to standard c compiled executables

I am compiling ngspice. Its configure.ac adds -fvisibility=hidden to all compile steps, not only during generating the 'code models' that are shared libs. Is there a risk if -fvisibility=hidden is added during compiling of the standard executable?
Holger
  • 41
  • 3
3
votes
1 answer

Get C/CXX FLAGS set by commands add_definitions() and add_compile_options()

In my CMakeLists.txt, global C and CXX flags are set using commands add_definitions() and add_compile_options. Many attempts to retrieve the C/CXX flags: ${CMAKE_C_FLAGS} and ${CMAKE_CXX_FLAGS} are empty ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} is the…
oHo
  • 51,447
  • 27
  • 165
  • 200
3
votes
1 answer

CFLAGS and LDFLAGS vs CPATH and LIBRARY_PATH

in this thread https://unix.stackexchange.com/questions/149359/what-is-the-correct-syntax-to-add-cflags-and-ldflags-to-configure someone says that CFLAGS and LDFLAGS do not work with every configure script. Why? I would like to have more explanation…
user3182532
  • 1,097
  • 5
  • 22
  • 37
1
2 3 4 5