Sunday, March 13, 2011

Adventures in CFLAGS

For those who don't know what CFLAGS is, it is a variable in Makefile, that is the file that appears in every directory of your program that lists the flags gcc uses, such as -Wall or -g . In this case, I want the debugger flag -g, but unfortunetly, I have to go and edit the 25-30 or so different Makefiles by hand to change the CFLAGS. I figure there has to be a better way to get the debugger to work, but every time I run ./configure even when I try to change the enviroment variable by adding something like ./configure $CFLAGS = "-g" or something, it doesn't work. I tried it forwards, backwards, with export, and still the configure keeps giving me the same makefiles with nothing added for the CFLAGS. I'm going to read through the entire autoconf and automake file. I've already been looking through them trying to understand what the various macros do in the configure.ac, I'm still not 100% sure what all those different configure files do yet. I'll probably have to run autotools and rebuild the configure again. I was hoping there would be some simple command line thing I could do, but for some reason this does not appear to be the case. I've also heard about changing enviroment variables, but I have no idea how to do that.

Wednesday, March 9, 2011

Bug hunting, the continuing story of gdb

Finding the bugs and using gdb is not so simple as it first seemed. First I tried to compile all those files with the -g option, but even after asking around, I could not get it to give me the exact line in the program where I was getting the segfault error. The lead programmer had not made any progress with it for several months. He is useless now, it seems, so I will have to do something I have never done before, find the bugs in wogedit, and fix them myself.
I ran some x11 tutorials in gdb. They work great, and gdb gives me the line number when I introduce bugs (I quickly found a way to add a segmentation fault bug to the x11 tutorial) . So it seems I am stuck looking at flags in the makefiles. For some reason, the flag FFLAGS, a flag that is supposed to be for the fortran compiler is where my -g flag is showing up. I thought it would give me the c flags instead, but it does not seem to be doing that. I wonder why the makefiles include it. I know this project still has strange bits of code I have not looked at yet, but as far as I know, it does not use any fortran. I don't even think I have this F77 compiler installed on my machine. I don't know anyone who uses fortran for anything nowadays.
So, I am reading up on autoconf, automake, and make in hopes that I can solve this mystery before I die of old age.