C_makefile

https://www.sharetechnote.com/html/C_makefile.html

makefile

As you know, in order to execute the program written in C, we need to do compilation and link to convert the c source code to an executable binary file. This compilation and link process would not be a big issue if you are handling a small number of c files and h files, but the process would go more and more complicated as the number of those files increases and you need to use more complicated compilation / link options. Repeating those compilation and link process over and over can be an annoying process. makefile is a kind of batch file (similar to shell program) that execute the predefined compilation/link procedure.

 

如果你曾经尝试过使用任何大规模的程序(比如那些你可以从互联网或github上获取的开源程序),你就会发现大多数程序的源代码都附带有自己的makefile,并且理解这些makefiles的内容并不是一件容易的事情。

 

本说明旨在帮助你理解那些程序提供的makefile的内容,并帮助你为你自己的程序创建makefiles。

 

无makefile编译

最简单的makefile

带有宏的最简单makefile

特殊符号

#include "hello.h"

int main(void)

{

print_hello();

 

    return 1;

 

}

 

#include <stdio.h>

 

 

 

void print_hello(void)

 

{

 

     printf("Hello World \n");

 

}

 

 

 

 

 

# gcc hello.c -o hello.o

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值