GCC的DEBUG和release版本编译方法
2011-12-05 19:15
260 查看
利用gcc的 -DDEBUG选项。
1. 源文件DEBUG.c中有:
#include <stdio.h>
int main(int argc, char *argv[])
{
#ifdef DEBUG
printf("DEBUG is definded \n");
#else
printf("DEBUG is not definded \n");
#endif
}
2. Makefile文件为:
DEBUG=
CFLAG= -g
debug: DEBUG.c
gcc $(DEBUG) $(CFLAG) -o $@ $^
3. 输入:gcc -g -o debug DEBUG.c
./debug
out: DEBUG is not definded
4. 输入:gcc -DDEBUG -g -o debug DEBUG.c
./debug
out: DEBUG is definded
这样 DEBUG版本和 release版本都有了.
1. 源文件DEBUG.c中有:
#include <stdio.h>
int main(int argc, char *argv[])
{
#ifdef DEBUG
printf("DEBUG is definded \n");
#else
printf("DEBUG is not definded \n");
#endif
}
2. Makefile文件为:
DEBUG=
CFLAG= -g
debug: DEBUG.c
gcc $(DEBUG) $(CFLAG) -o $@ $^
3. 输入:gcc -g -o debug DEBUG.c
./debug
out: DEBUG is not definded
4. 输入:gcc -DDEBUG -g -o debug DEBUG.c
./debug
out: DEBUG is definded
这样 DEBUG版本和 release版本都有了.
相关文章推荐
- vs中debug和release版本的同时编译方法
- VC++6.0怎么编译Debug版本和Release版本。
- 编译成release版本与debug版本的程序有何执行上的区别?
- iOS开发debug跟release版本log屏蔽方法
- iOS开发debug跟release版本NSLog屏蔽方法
- iOS开发debug跟release版本屏蔽NSLog方法
- iOS开发debug跟release版本log屏蔽方法
- 如何指定让Android的NDK工具编译出Release版本或Debug版本的Native程序
- GCC 64位程序的makefile条件编译心得——32位版与64位版、debug版与release版(兼容MinGW、TDM-GCC)
- 转 iOS开发debug跟release版本log屏蔽方法
- GCC 64位程序的makefile条件编译心得——32位版与64位版、debug版与release版(兼容MinGW、TDM-GCC)
- 将编译AS3区分Debug版本和Release版本
- 【转】 iOS开发:Debug与Release版本NSLog屏蔽方法
- VC6.0如何编译生成Release或Debug版本?
- iOS开发debug跟release版本NSLog屏蔽方法
- 编译产生debug以及release版本 autotool工具
- 嵌入式 GCC 64位程序的makefile条件编译心得——32位版与64位版、debug版与release版(兼容MinGW、TDM-GCC)
- 将编译AS3区分Debug版本和Release版本
- VS编译时自动引用Debug|Release版本的dll
- qt条件编译debug和release版本--qmake之CONFIG(debug, debug|release)