如何添加一个调试选项Makefile文件 [英] How do I add a debug option to Makefile

查看:101
本文介绍了如何添加一个调试选项Makefile文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下简单的makefile,我用编译C程序:

I've got the below simple Makefile which I use for compiling a C program:

all:
    gcc -Wall -o myfile myfile.c lol_dht22/dht22.c lol_dht22/locking.c -lwiringPi -lcurl -lm

我想在调试选项添加这样我就可以-DDEBUG编译,所以如果我跑

I want to add in a debug option so I can compile with -DDEBUG, so if I run

make

它编译正常。如果我跑

it compiles as normal. and if I run

make debug

它与调试标志compliles。

it compliles with the debug flag.

我已经通过一些教程读取,但似乎是越来越糊涂了。

I have read through a few tutorial but seems to be getting more and more confused.

推荐答案

下面是有你正在寻找这两个选项的示例生成文件。

Here's an example makefile that has the two options you are looking for.

all:
    gcc -Wall -o myfile myfile.c lol_dht22/dht22.c lol_dht22/locking.c -lwiringPi -lcurl -lm
debug:
    gcc -DDEBUG -Wall -o myfile myfile.c lol_dht22/dht22.c lol_dht22/locking.c -lwiringPi -lcurl -lm

您只需要添加一个调试选项,这在类似的方式做你已经宣布全部选项。

You just needed to add a debug option, which is done in similar fashion to the 'all' option you had already declared.

这篇关于如何添加一个调试选项Makefile文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆