1

Here are two separate questions.

Firstly, is it possible to modify a makefile so that it produces a.out that is readable by GDB? Secondly, in a makefile, how to disable all the warning messages on the screen output?

Here is the content of the makefile:

ALL: timefield eqloc3d getdat

timefield: timefield.c common.c common.h getpar.c time_3d.c modresample.c eq.c eq.h
    cc timefield.c common.c getpar.c time_3d.c modresample.c eq.c ./libgeo.a -lsunmath -lm -g -o timefield

eqloc3d: deri.c eqloc3d.c getpar.c main.c  modresample.c common.h common.c modifyxy.c modifyxyz.c eqloc3d.h eq.c eq.h model.h initeqloc.h initeqloc.c
    cc deri.c eqloc3d.c getpar.c main.c modresample.c common.c modifyxy.c modifyxyz.c eq.c initeqloc.c ./libgeo.a -lsunmath -lm -xlic_lib=sunperf -g -o eqloc3d

getdat: eq.c eq.h getdat.c
    cc -g eq.c getdat.c -o getdat libgeo.a -lm

If I run the makefile, it creates three binary executables: timefield, eqloc3d, getdat. Once the program is not producing correct outputs, I do not have an a.out so that I can use GDB to trace exceptions.

IPython
  • 91
  • 1
  • 9
  • 1
    You want to know how to suppress warning messages from the compiler, and how to enable the debugger. Think about that. – Beta Mar 26 '17 at 15:15

1 Answers1

1

why you need a.out??

based on your makefile, your makefile generates 3 executable. and they are getting generated.....

first question:

yes. you have to add "-g", to make the executable debug-gable. In the makefile,you posted, all three executables getdat,timefield and eqloc3d already built using "-g".

So the executable are ready to debug. Just you need to call as shown below.

$ gdb getdat 

or $ gdb timefield

or $ gdb eqloc3d

Then set break points and call run with appropriate arguments if any.

Second question:

use -w to Inhibit all warning messages.

ex:

cc -w -g eq.c getdat.c -o getdat libgeo.a -lm
Pavan Chandaka
  • 11,671
  • 5
  • 26
  • 34