4
22
2014
3

关于怎么写MakeFile

先看下面一个MakeFile的例子

cache: test.o happyhut_list.o
	gcc -g test.o happyhut_list.o -o cache -lpthread 

happyhut_list.o: happyhut_list.c happyhut_list.h plus.h
	gcc -g -c happyhut_list.c -o happyhut_list.o

test.o: test.c plus.h raid.h
	gcc -g -c test.c -o test.o

clean:
	rm -rf *.o cache

编译的过程从下往上执行。首先执行clean部分,rm -f表示force,强制执行,-r表示递归删除,即目录和子目录

然后生成test.o文件

test.o:冒号后的东西表示生成test.o所需要的东西。

以此往上生成。最后生成可执行文件cache。

gcc -g 是为了gdb调试,-c 表示只编译,不链接。

下面说说源代码变成可执行代码在内存中执行的三个步骤:

编译、链接、载入

1.编译:将原代码编译成若干个目标模块。

2.链接:将编译后形成的目标模块和库链接在一起,形成一个完整的载入模块。

3.载入:将载入模块载入内存

具体可以看

http://blog.csdn.net/monkey_d_meng/article/details/5651649


Category: 脚本语言 | Tags: | Read Count: 965
Avatar_small
Alyssa 说:
2023年1月07日 20:26

A Makefile is a text file that contains instructions on how to compile and link a program. It is usually used in conjunction with a C or C++ compiler. Makefiles can be used to automate the process Lab grown diamonds of compiling and linking programs. To use a Makefile, you need a text editor. Makefiles are typically written in the GNU Make language, which is a variant of the Unix make utility. To learn more about the GNU Make language, see the GNU Make Manual.

Avatar_small
IndusInd Bank Login 说:
2023年1月19日 15:31

Indusind Bank is quite well known as it provides all essential banking services without many fees that have garnered them a lot of customers over the years. If you are someone who has an IndusInd bank account then you might know how great their service is. IndusInd Bank Login They provide different banking services from setting up of savings, and personal accounts, providing loans, and credit and debit cards as well. Now with internet banking on the rise, they have made their IndusInd bank login process quite easy.

Avatar_small
WBBSE 7th Class Boo 说:
2023年7月14日 18:13

WBBSE Board of Secondary Education is the West Bengal state Government Administered Autonomous Examining Authority are Published by English, Bengali Medium Textbooks from Standard 7th Addition, WBBSE Every Year Publish and Distribution WBBSE 7th Class Books 2024 West Bengal Std 7th Class Textbook 2024 for High School Students Study Purpose,The Printed WBBSE 7th Class Textbook 2024 are Distributed Through Cooperative Institutions All over Gujarat. Vendors are Linked to the Distribution of Textbooks with Distributors in each District. West Bengal Board Class Book 2024 are easily Accessible to All Students of This System.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com