[英]Makefile, Don't know how to make target
I tried running the following Makefile 我尝试运行以下Makefile
SRC=../src
INC=../inc
OBJS=$(SRC)/rrbsSimulator.o \
$(SRC)/XMLParser.o
ALLOBJS=rrbsSimulator.o \
XMLParser.o
CC=/usr/sfw/bin/gcc
FLAGS= -Wall -g -m64
AINC=-I$(INC)
ALLLIBS=-lcc -lsocket -lnsl -lpthread -lstdc++
%.o: %.cpp
$(CC) $(AINC) $(FLAGS) -c $<
lcc: $(ALLOBJS)
$(CC) $(FLAGS) $(ALLLIBS) $(ALLOBJS) -o lycaUSSDSIM
mv lycaUSSDSIM ../bin
clean:
rm -f $(ALLOBJS) ../bin/lycaUSSDSIM
I am getting the following error 我收到以下错误
make: Fatal error: Don't know how to make target `rrbsSimulator.o'
What is the mistake I have done? 我犯了什么错误?
The error Don't know how to make target
rrbsSimulator.o'` means one of two things. 错误
Don't know how to make target
rrbsSimulator.o”意味着两件事之一。 Either 要么
This looks like a valid rule. 这看起来像是一条有效规则。
%.o: %.cpp
$(CC) $(AINC) $(FLAGS) -c $<
Therefore the most likely cause is that its dependency, with the suffix of cpp, is missing. 因此,最可能的原因是缺少其后缀cpp的依赖性。 Look for
rrbsSimulator.cpp
in the relevant source folder. 在相关的源文件夹中查找
rrbsSimulator.cpp
。
Unfortunately makefiles used by some legacy versions of make
are ridiculously picky over formatting like spaces and tabs, and it's not possible to see those in this format. 不幸的是,某些旧版
make
所使用的makefile对空格和制表符等格式的选择非常可笑,因此无法看到这种格式的文件。 If you are using one of those make
s you need to check the whitespace carefully. 如果使用的是这些
make
之一,则需要仔细检查空白。
Where do your source files situated? 您的源文件在哪里?
Looking at SRC
and OBJS
variables I can imagine that your source code files are placed in ../src folder. 查看
SRC
和OBJS
变量,我可以想象您的源代码文件位于../src文件夹中。 But %.o : %.cpp
will search for both *.o and *.cpp files in the current directory. 但是
%.o : %.cpp
将在当前目录中搜索* .o和* .cpp文件。 Thus it would not find neither rrbsSimulator.o nor rrbsSimulator.cpp. 因此,找不到rrbsSimulator.o和rrbsSimulator.cpp。
Btw, why don't you use a standard CFLAGS
variable instead of yourown FLAGS
? 顺便说一句,为什么不使用标准
CFLAGS
变量而不是自己的FLAGS
? and you better write it this way: 而你最好这样写:
FLAGS += -Wall -g -m64
What if you would like to add some extra flags from command line later on? 如果您以后想要从命令行添加一些额外的标志怎么办? This will let you call your makefile in this way:
这将使您以这种方式调用您的makefile:
make FLAGS=-s
Add VPATH = $(SRC) it will work. 添加VPATH = $(SRC),它将起作用。 Also need to concentrate with spacing when we implementing Makefile.
在实现Makefile时,还需要集中注意间距。
rrbsSimulator.cpp不存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.