Lai Yu-Hsuan
Lai Yu-Hsuan

Reputation: 28081

wildcard target in makefile doesn't work

I have this simple rule in my Makefile:

PP=g++ -std=c++0x
%.o: $.cpp
        $(PP) $< -c -o $@

When I run make parse_utils.o, the command be executed should be:

g++ -std=c++0x parse_utils.cpp -c -o parse_utils.o

But in fact it's:

>make parse_utils.o
g++    -c -o parse_utils.o parse_utils.cpp

And I got a compile error because I used C++11 syntax.

Is this wildcard rule wrong?

Upvotes: 0

Views: 737

Answers (1)

user529758
user529758

Reputation:

Your target is wrong. Change

%.o: $.cpp

to

%.o: %.cpp

Upvotes: 1

Related Questions