Compile Option and Bactrace

i wann to know where the SEGV(Segmentation Fault) has occurred
to fixe application killed issue.
i used to add SEGV Signal handler and backtrace function.

for that i have to compile all sources using "-g"option
Aynbody know how to do this?
or i want to know how to use backtace function, just to include is it enough? if anybody know that or have experience about that. please share that experience.

likely libc too. and anything else in ldd output