View Full Version : make with debug options

01-13-2010, 09:38 AM
Hello I'm playing with an opensource project openbsc.
Now I want build the project with debug info. When I add -g3 and O0, somehow during build (by typing "make") it overruled by -g -O2.

So I asked a dude on IRC how to get the debug info in the executable and that guy said something with: make CFLAGS=-g3 -O0 // I don't remember exactly.
That worked for me, I was really happy to debug properly. But now I forgot how to do it, cause I get an error from make.

I tried:
make CFLAGS=-g3 -O0
make $CFLAGS=-g3 -O0
but these result in invalid options...

Does someone know how to do it the right way?


01-13-2010, 10:38 AM
I think you may need to do
CFLAGS=-g3 -O0 make as you are attempting to set the environmental variable for the make command to read.

01-13-2010, 11:33 AM
Quote it.

make CFLAGS='-g -O0'

-g3 is redundant. -g is all you need.

01-13-2010, 11:48 AM
If this project uses autoconf, you can specify the CFLAGS during the configure run.

./configure CFLAGS=-'g -O0'

01-19-2010, 10:24 AM
Hey guys thanks!

make CFLAGS='-g -O0'

worked for me.
Bithub, I'll keep your advise in my mind.