“多个目标模式”生成文件错误

我的 makefile 错误地失败了:

Makefile:34: *** multiple target patterns.  Stop.

这到底是什么意思,我该怎么补救?

(显而易见的船长写的 GNU 制作手册没什么帮助)。


找到了,我有规矩:

$(FOO): bar

其中 FOO是从 shell 命令设置的,后者用包含冒号的错误消息污染了它。

148929 次浏览

I had it on the Makefile

MAPS+=reverse/db.901:550:2001.ip6.arpa
lastserial:  ${MAPS}
./updateser ${MAPS}

It's because of the : in the file name. I solved this with

-------- notice
/    /
v    v
MAPS+=reverse/db.901\:550\:2001.ip6.arpa
lastserial:  ${MAPS}
./updateser ${MAPS}

Besides having to escape colons as in the original answer, I have found if the indentation is off you could potentially get the same problem. In one makefile, I had to replace spaces with a tab and that allowed me to get past the error.

I just want to add, if you get this error because you are using Cygwin make and auto-generated files, you can fix it with the following sed,

sed -e 's@\\\([^ ]\)@/\1@g' -e 's@[cC]:@/cygdrive/c@' -i filename.d

You may need to add more characters than just space to the escape list in the first substitution but you get the idea. The concept here is that /cygdrive/c is an alias for c: that cygwin's make will recognize.

And may as well throw in

-e 's@^ \+@\t@'

just in case you did start with spaces on accident (although I /think/ this will usually be a "missing separator" error).

I had this problem (colons in the target name) because I had -n in my GREP_OPTIONS environment variable. Apparently, this caused configure to generate the Makefile incorrectly.

I met with the same error. After struggling, I found that it was due to "Space" in the folder name.

For example :

Earlier My folder name was : "Qt Projects"

Later I changed it to : "QtProjects"

and my issue was resolved.

Its very simple but sometimes a major issue.

My IDE left a mix of spaces and tabs in my Makefile.

Setting my Makefile to use only tabs fixed this error for me.

I also got this error (within the Eclipse-based STM32CubeIDE on Windows).

After double-clicking on the "multiple target patterns" error it showed a path to a .ld file. It turns out to be another "illegal character" problem. The offending character was the (wait for it): =

Heuristic of the week: use only [a..z] in your paths, as there are bound to be other illegal characters </vomit>.

The GNU make manual doesn't explicitly document this.

I got the same error and my issue was an extra whitespace and a backslash at the end of listing source files:

SRCS := ft_striteri.c \
ft_putchar_fd.c \
ft_putstr_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c \
BONUS_SRCS :=   ft_lstadd_back.c \
ft_lstadd_front.c \
ft_lstlast.c \
ft_lstnew.c \
ft_lstsize.c

The correct version that works looks like this:

SRCS := ft_striteri.c \
ft_putchar_fd.c \
ft_putstr_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c
BONUS_SRCS :=   ft_lstadd_back.c \
ft_lstadd_front.c \
ft_lstlast.c \
ft_lstnew.c \
ft_lstsize.c