开发者

GNU make not recognizing %

开发者 https://www.devze.com 2023-01-24 02:02 出处:网络
I\'m trying to make a makefile for compiling various examples that are within a subfolder. The makefile consisting of just:

I'm trying to make a makefile for compiling various examples that are within a subfolder. The makefile consisting of just:

S_1_2.exe : Twister.cpp Parsing.cpp ./Surfaces/S_1_2.cpp
    g++ -o $@.exe $^ -I . -W -Wall

Works fine when run with the command "make S_1_2.exe". However:

%S_1_2.exe : Twister.cpp Parsing.cpp ./Surfaces/S_1_2.cpp
    g++ -o $@.exe $^ -I . -W -Wall

fails, even when run with the command make S_1_2.exe, with the error "make: * No rule to make target 'S_1_2.exe'开发者_C百科. Stop."

Shouldn't %S_1_2.exe do pattern matching and so match S_1_2.exe? In which case why is it not matching this rule?

I am using GNU Make 3.81


The percentage symbol matches a non-empty string. So you should use %_1_2.exe or better yet - %.exe. I don't know if there is any other symbol that matches empty strings too.


The % is for matching a part of the target against the same part in one or more dependencies. You can't omit it from all dependencies.

0

精彩评论

暂无评论...
验证码 换一张
取 消