105

My makefile fails with error:

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

What does it really mean, how can I fix this?

(GNU make manual, written by Captain Obvious, isn't helping).


Found it. I had rule in form:

$(FOO): bar

where FOO was set from shell command that polluted it with error message that contained a colon.

Kornel
  • 97,764
  • 37
  • 219
  • 309
  • does http://www-01.ibm.com/support/docview.wss?uid=swg21119863 or http://sourceware.org/ml/crossgcc/2009-07/msg00006.html help? – Alok Singhal Jan 20 '10 at 10:05
  • 2
    A swift google reveals http://groups.google.com/group/gnu.utils.help/browse_frm/thread/d7eeff06e2b8394/1c932a7ea7664ade?lnk=st&q=%22multiple+target+patterns%22&rnum=7#1c932a7ea7664ade –  Jan 20 '10 at 10:08
  • These answers are just paraphrases of "you've got multiple target patterns". Well, I think I don't. How can I check it? What can trigger it? What precautions are needed to prevent this problem? – Kornel Jan 22 '10 at 22:39
  • 2
    Everything was working one minute and then my script sneezed out a (semi)colon... heheh. Sweated it out trying to find the problem for at least 3 hours before I found your and @mcr 's answer. You just saved me a bucketful of sweat!! – GuruM Jan 06 '12 at 04:46
  • The true root cause of this problem is GNU Make being a horrible piece of dung that should have died decades ago. – antred Apr 09 '18 at 13:56

9 Answers9

74

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}
Zombo
  • 1
  • 62
  • 391
  • 407
mcr
  • 4,615
  • 2
  • 31
  • 30
  • 1
    i have the same problem, but i don't understand your answer, will you elaborate this further for me, – Pir Fahim Shah Jan 11 '13 at 20:08
  • 4
    @PirFahimShah The answer is stating that the colons in the filename (db.901:550:2001.ip6.arpa) need to be escaped. mcr is escaping the colons by putting a backslash before them. That way, make does not interpret the colons as a special symbol. – Loduwijk Aug 18 '16 at 14:04
  • 1
    Thanks, it worked for me. I had some old windows path with colon in it (`C:/Qt/5.8/mingw53_32/bin/rcc.exe`) in one of Makefile rules. Remove those autogenerated makefiles if you are building on Linux machine – Vadim Kotov Jul 14 '17 at 14:18
  • windows make switched to wsl (ubuntu) and got this error, `make clean` followed by `make` solved it. The erroneous line was `_build/nrf52840_xxaa/app_mpu.c.o: ../../../app_mpu.c \ ` – Tyeth Dec 15 '20 at 18:59
35

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.

davenpcj
  • 12,508
  • 5
  • 40
  • 37
demongolem
  • 9,474
  • 36
  • 90
  • 105
4

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).

Zombo
  • 1
  • 62
  • 391
  • 407
4

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.

skg
  • 948
  • 2
  • 19
  • 35
3

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

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

Paul Wenzel
  • 1,886
  • 2
  • 15
  • 15
1

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
ialinaok
  • 11
  • 1
  • I dont think the whitespace was the issue here. With the errant \ you were actually including `BONUS_SRCS :=` in SRCS. Not the definition, but the the literal text. Then, as others pointed out, you would receive this error because of the `:` in the rules using this "source file" – sherrellbc Nov 25 '22 at 15:07
0

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.

Trebor Rude
  • 1,904
  • 1
  • 21
  • 31
0

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.

user103185
  • 925
  • 2
  • 8
  • 20
0

I got this error and it was because I used explorer to copy/paste a directory into Windows Subsystem For Linux. Owner of all the files was root, but my WSL user was art. When I tried moving or modifying any files in the directory as user art I got permission denied.

I gave it a sudo chown -R <my user name> <path to my containing folder> to change the file owner to myself and it built after that.

ArtHare
  • 1,798
  • 20
  • 22