简体   繁体   English

Makefile:无规则可作为目标。 停止

[英]Makefile: No rule to make target. Stop

i'm new to Makefile . 我是Makefile新手。 I've to write a Makefile to build a shared libary. 我必须编写一个Makefile来构建共享库。

CC =g++
CFLAGS =-fPIC -Wall -Wextra -c
LDFLAGS =-shared
RM =rm -rf
TARGET_LIB =lib/Automat.so

SRC_DIR =src/
LIB_DIR =lib/
DEP_DIR =dep/

SRCS=IFSM.h IState.h ITransition.h FSM.h State.h Transition.h Wildcard.h PrimeTransition.h SingleTransition.h Exception.h Type.h Error.h
OBJS=$(SRCS:.h=.o)

.PHONY: all
all: $(TARGET_LIB)

$(TARGET_LIB): $(SRC_DIR)$(OBJS)
    $(CC) $(LDFLAGS) -o $@ $^

$(SRC_DIR)$(SRCS:.h=.d):%.d:$(SRC_DIR)%.h
    $(CC) $(CFLAGS) -MM $< > $(DEP_DIR)$@

include $(SRCS:.h=.d)

My problem is that i get the error 我的问题是我得到了错误

No rule to make target `IFSM.d'. 没有规则将目标设为IFSM.d。 Stop. 停止。

If i remove to file from SRCS the problem occurs with IState.d . 如果我从IState.d删除文件,则IState.d SRCS出现问题。 All other .d files where builded correct (11 of 12). 构建正确的所有其他.d文件(12个中的11个)。

All files exists and they are written correct (case-sensitiv). 所有文件都存在,并且被正确写入(区分大小写)。

I rly don't know where the error could be and i was searching for 2 hours now. 我不知道错误可能在哪里,我现在正在搜索2个小时。

Any help would be great. 任何帮助都会很棒。

Best regards Alex 最好的问候亚历克斯

You are including 你包括

$(SRCS:.h=.d)

that is, files called whatever.d in the local directory; 也就是说,在本地目录中名为whatever.d的文件; but you have a rule to make 但是你有一条规则要制定

$(SRC_DIR)$(SRCS:.h=.d)

that is, files called src/whatever.d . 也就是说,文件名为src/whatever.d

You need to decide where these files should live, and make both rules match. 您需要确定这些文件应该存放在哪里,并使两个规则匹配。

Make sure that you are using tabs for indentation. 确保您使用制表符进行缩进。 Such mysterious failures are usually caused by using spaces, which are not supported by make. 这种神秘的故障通常是由使用空格引起的,make不支持这些空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM