Skip to content
Advertisement

What is cflags’s function?

In this issue, CFLAGS set as path:

https://unix.stackexchange.com/questions/149359/what-is-the-correct-syntax-to-add-cflags-and-ldflags-to-configure

In this issue, CFLAGS set as compile option:

How to use LDFLAGS in makefile

I am confused.

Advertisement

Answer

CFLAGS stands for compiler flags. LDFLAGS is for linker flags.

CFLAGS is used to pass flags to tell the compiler information on how to build a file(s).

In your link it is used to pass the path of header file so that the compiler knows where to find them. This is done with the -I flag and is used like this: -I<path>. There are many flags you can pass to the compiler. Some common ones are:

  • -c : compile only (don’t link). This is used to compile a c/cpp file into an object (.o) file.
  • -o : output name. This is used to specify the output name. E.g. gcc -c fred.c -o fred.o or gcc fred.c -o fred
  • -I : this is used (as explained above) to add an include path: -I. includes the current directory. -Ianother/sub/dir includes ./another/sub/dir. Note there is no space after the -I.

Your best bet is to start with a really basic tutorial (don’t worry it gets advance quite quickly):

Like this or this

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement