作为一个合格的嵌入式程序员一定要会写 makefile, 本篇博文就是记录我是从零开始学习makefile
首先是最简单的helloworld c 代码
helloworldsingle.c
#include <stdio.h>
int main()
{
printf("hello world \n");
printf("version 0.1");
return 1;
}
然后是Makefile的代码:
hello.exe: hello.o
gcc hello.o -o hello.exe
hello.o: helloworldsingle.c
gcc -c helloworldsingle.c -o hello.o
clean:
rm -rf *.o *.exe
打开cygwin 到文件所在目录
$ cd "E:\learnfile\learn ex\makefile_helloworld"
命令:
make
./hello.exe
perfect!