错误的makefile([否输入文件") [英] Error in makefile ("no input files")

查看:399
本文介绍了错误的makefile([否输入文件")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的绝对第一次做一个makefile,和我真的想了解的过程。

我试图创建一个C ++项目,其结构如下一个非常简单的makefile:

根文件夹

     makefile文件

    自述

src文件夹

    的 ...源文件都在这里...

包含文件夹

    的 ...外部库头文件在这里...

lib文件夹

    的 ...外部LIB文件都在这里...

bin文件夹

    的 ...为生成的可执行文件... 的输出目录

     OBJ文件夹

    的 ...对象文件都在这里...

我也跟着教程这里

下面是我的makefile:

  IDIR =包括。
CC = G ++
CFLAGS = -I $(IDIR)
ODIR =斌/ OBJ
LDIR = LIB
LIBS =无
SRC = SRC
_DEPS = hello.h
DEPS = $(patsubst%,$(IDIR)/,%(_ DEPS))
_OBJ = file1.o file2.o
OBJ = $(patsubst%,$(ODIR)/%,$(_ OBJ))$(ODIR)/%○:。$(SRC)/ CPP%$(DEPS)
    $(CC)-c -o $ @ $< $(CFLAGS)#$(LIBS)test_proj:$(OBJ)
    $(CC)-o $ @ $ ^ $(CFLAGS).PHONY:干净清洁:
    RM -f $(ODIR)/ *。Ø*〜$核心(INCDIR)/ *〜

当我运行制作此,我得到以下错误:

  G ++的.o -o
G ++:致命错误:没有输入文件
编译终止。
<内置的计算值:配方目标的.o'失败
的mingw32-的make.exe:*** [的.o]错误1

我使用GNU做3.82.90针对i686-PC-mingw32的建成,如果该事项在所有。

任何人都可以指出我在做什么可笑的错误?


解决方案

  IDIR =包括。

是第一个问题。通过替换它:

  IDIR =包括

通过您的code CFLAGS 被扩展为:

  -Iinclude。

这是没有意义的,我害怕。第二个问题是:

  DEPS = $(patsubst%,$(IDIR)/,%(_ DEPS))

这或许应该是:

  DEPS = $(patsubst%,$(IDIR)/%,$(_ DEPS))

和会扩展为:

  DEPS =包括/ hello.h

如果你解决了第一个问题,其他如:

  DEPS =包括./hello.h

这没有意义也没有。这两个错误的累积效应很奇怪的食谱(我没有尝试用手将其展开),这可能引发与错误的参数的化妆隐含规则。

This is my absolute first time ever making a makefile, and I'm really trying to understand the process.

I'm trying to create a very simple makefile for a C++ project whose structure is as follows:

root folder
    makefile
    readme
src folder
    ...source files all here...
include folder
    ...header files for external libraries here...
lib folder
    ...external lib files all here...
bin folder
    ...output directory for built executable...
    obj folder
    ...object files all here...

I followed the tutorial here.

Here's my makefile:

IDIR=include .
CC=g++
CFLAGS=-I$(IDIR)
ODIR=bin/obj
LDIR=lib
LIBS=none
SRC=src


_DEPS=hello.h
DEPS=$(patsubst %,$(IDIR)/,%(_DEPS))
_OBJ=file1.o file2.o
OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ))

$(ODIR)/%.o: $(SRC)/%.cpp $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS) # $(LIBS)

test_proj: $(OBJ)
    $(CC) -o $@ $^ $(CFLAGS)

.PHONY: clean

clean:
    rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~

When I run make on this, I get the following error:

g++      -o .o
g++: fatal error: no input files
compilation terminated.
<builtin>: recipe for target '.o' failed
mingw32-make.exe: *** [.o] Error 1

I'm using GNU Make 3.82.90 built for i686-pc-mingw32, if that matters at all.

Can anyone point out whatever ridiculous error I'm making?

解决方案

IDIR=include .

is the first problem. Replace it by:

IDIR=include

With your code CFLAGS is expanded as:

-Iinclude .

It does not make sense, I'm afraid. The second problem is:

DEPS=$(patsubst %,$(IDIR)/,%(_DEPS))

which should probably be:

DEPS=$(patsubst %,$(IDIR)/%,$(_DEPS))

and would expand as:

DEPS=include/hello.h

if you fix the first problem, else as:

DEPS=include ./hello.h

which does not make sense neither. The cumulated effect of these two errors are strange recipes (I didn't try to expand them by hand) that probably trigger a make implicit rule with wrong parameters.

这篇关于错误的makefile([否输入文件&QUOT;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆