本文介绍了makefile编译多个C程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Increadibly简单的问题,但我是新来的makefile,我试图做一个makefile,将编译应用两个独立的程序。所有在线的例子进入的方式更多的细节比我更需要,而且混乱!

Increadibly simple question but I'm new to makefiles and am trying to make a makefile that will compile two independant programs. All the examples online go into way more details than I need and are confusing!

我有以下内容:

program1:
    gcc -o prog1 program1.c

program2
    gcc -o prog2 program2.c

我真正想要做的它是运行在两个gcc的线条。我在做什么错了?

All I really want it do is to run the two gcc lines. What am I doing wrong?

推荐答案

做到像这样

all: program1 program2

program1: program1.c
    gcc -o program1 program1.c

program2: program2.c
    gcc -o program2 program2.c

你说你不想先进的东西,但你也可以缩短它像这样基于一些默认规则。

You said you don't want advanced stuff, but you could also shorten it like this based on some default rules.

all: program1 program2

program1: program1.c
program2: program2.c

这篇关于makefile编译多个C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 01:05