Timeline for Makefile error when .PHONY target doesn't contain the output file names
Current License: CC BY-SA 4.0
Post Revisions
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 23, 2025 at 4:07 | vote | accept | Harry | ||
| Dec 22, 2025 at 18:22 | answer | added | David Maze | timeline score: 1 | |
| Dec 22, 2025 at 16:14 | comment | added | Harry |
@DavidMaze After changing to all: $(SOLIBNAME) $(BINNAME) and .PHONY: all clean, the build is successful. In case, I only want to build the shared library I need to issue the command make libfoo.so.0.1 right? Or Is there a more idiomatic way since library version keeps changing.
|
|
| Dec 22, 2025 at 15:54 | review | Close votes | |||
| Dec 26, 2025 at 0:04 | |||||
| Dec 22, 2025 at 15:33 | comment | added | John Bollinger |
The modification of LIB_LDFLAGS is not relevant to your particular diagnostic, which is about dependencies between rules, because LIB_LDFLAGS is used only in recipes, not in the target or prerequisite list of any rule.
|
|
| Dec 22, 2025 at 15:31 | comment | added | John Bollinger |
I can't reproduce your error, which is what I expected from analyzing the makefile presented. I created dummy sources lib/src/abc.cpp and exe/src/main.cpp, each containing exactly one function, the latter's being a main(). I used your makefile unmodified except for changing the value of LIB_LDFLAGS to empty to avoid dealing with whatever your libads is. make successfully built a working bar executable, issuing the usual echo of the commands it was running but no diagnostic messages.
|
|
| Dec 22, 2025 at 13:39 | comment | added | David Maze |
Your target named foobuild should be named $(SOLIBNAME) – the name of the file the rule generates – and it shouldn't be phony. Maybe break this up into three separate targets to build the library itself and the related symlinks.
|
|
| S Dec 22, 2025 at 12:09 | history | suggested | ninadepina | CC BY-SA 4.0 |
improved formatting, better readability
|
| Dec 22, 2025 at 12:06 | review | Suggested edits | |||
| S Dec 22, 2025 at 12:09 | |||||
| Dec 22, 2025 at 11:42 | history | asked | Harry | CC BY-SA 4.0 |