告诉我有关makefile的信息 [英] Tell me about makefiles
问题描述
我已经理解程序编译是如何工作的(即
预处理器生成单独的翻译单元,它们分别编译为
,然后是链接器将目标文件链接在一起),但
我对makefile没什么了解。
如果我有以下程序:
/ * main.c * /
extern void Func(void);
int main(void )
{
Func();
返回0;
}
/ * func.c * /
#include< stdio.h>
void Func(void){puts (Hello World!); }
/ *代码结束* /
,然后我会用gcc编译如下:
gcc ac bc -ansi -pedantic -s -O3 -D NDEBUG -o prog.exe
我的makefile会是什么样的?
I already understand how program compilation works (i.e. the
preprocessor produces individual translation units which get compiled
separately, and then the linker links the object files together), but
I don''t know anything about makefiles.
If I had the following program:
/* main.c */
extern void Func(void);
int main(void)
{
Func();
return 0;
}
/* func.c */
#include <stdio.h>
void Func(void) { puts("Hello World!"); }
/* End of code */
, then I would compile it as follows with gcc:
gcc a.c b.c -ansi -pedantic -s -O3 -D NDEBUG -o prog.exe
What would my makefile for this look like?
推荐答案
Tomásóhéilidhe写道:
Tomás ó héilidhe wrote:
我已经理解程序编译是如何工作的(即
预处理器生成单独的翻译单元,它们分别编译为
,然后链接器将目标文件链接在一起),但
我什么都不知道关于makefile。
如果我有以下程序:
[...]
我的makefile是什么样的喜欢?
I already understand how program compilation works (i.e. the
preprocessor produces individual translation units which get compiled
separately, and then the linker links the object files together), but
I don''t know anything about makefiles.
If I had the following program:
[...]
What would my makefile for this look like?
看起来好像在讨论
comp.unix.programmer上讨论的东西比这里好。
-
Eric Sosman
es ***** @ ieee- dot-org.inva lid
It would look like something better discussed on
comp.unix.programmer than here.
--
Eric Sosman
es*****@ieee-dot-org.invalid
Tomásóhéilidhe说:
< snip>
Tomás ó héilidhe said:
<snip>
gcc ac bc -ansi -pedantic -s -O3 -D NDEBUG -o prog.exe
我的makefile是什么样的喜欢?
gcc a.c b.c -ansi -pedantic -s -O3 -D NDEBUG -o prog.exe
What would my makefile for this look like?
我不知道,但我的看起来像这样:
CC = gcc
CFLAGS = -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-ffloat-store - O2
DFLAGS = -g -pg
a:ao bo
I don''t know, but mine would look like this:
CC=gcc
CFLAGS=-W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-ffloat-store -O2
DFLAGS=-g -pg
a: a.o b.o
(CC)
这篇关于告诉我有关makefile的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!