使用 makefile 生成 a.out 并禁用警告消息
Producing a.out with makefile and disable warning messages
这里有两个不同的问题。
首先,是否可以修改 makefile 以生成 GDB 可读的 a.out?其次,在makefile中,如何禁用屏幕输出的所有警告信息?
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
如果我 运行 makefile,它会创建三个二进制可执行文件:timefield、eqloc3d、getdat。一旦程序没有产生正确的输出,我就没有 a.out 所以我可以使用 GDB 来跟踪异常。
为什么需要 a.out??
根据您的 makefile,您的 makefile 生成 3 个可执行文件。他们正在生成......
第一题:
是的。您必须添加“-g”以使可执行文件可调试。
在您发布的 makefile 中,所有三个可执行文件 getdat、timefield 和 eqloc3d 都已使用“- g".
因此可执行文件已准备好进行调试。只需要如下调用即可。
$ gdb getdat
或
$ gdb timefield
或$ gdb eqloc3d
然后设置断点并使用适当的参数调用run
。
第二题:
使用 -w
禁止所有警告消息。
例如:
cc -w -g eq.c getdat.c -o getdat libgeo.a -lm
这里有两个不同的问题。
首先,是否可以修改 makefile 以生成 GDB 可读的 a.out?其次,在makefile中,如何禁用屏幕输出的所有警告信息?
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
如果我 运行 makefile,它会创建三个二进制可执行文件:timefield、eqloc3d、getdat。一旦程序没有产生正确的输出,我就没有 a.out 所以我可以使用 GDB 来跟踪异常。
为什么需要 a.out??
根据您的 makefile,您的 makefile 生成 3 个可执行文件。他们正在生成......
第一题:
是的。您必须添加“-g”以使可执行文件可调试。 在您发布的 makefile 中,所有三个可执行文件 getdat、timefield 和 eqloc3d 都已使用“- g".
因此可执行文件已准备好进行调试。只需要如下调用即可。
$ gdb getdat
或
$ gdb timefield
或$ gdb eqloc3d
然后设置断点并使用适当的参数调用run
。
第二题:
使用 -w
禁止所有警告消息。
例如:
cc -w -g eq.c getdat.c -o getdat libgeo.a -lm