1

I'm facing an issue while running a makefile. The issue is after running the makefile I'm getting error

'linker' input unused [-Wunused-command-line-argument]

Screenshot of the error:

enter image description here

Moreover, when I use the make command with the file name, the commands works perfectly fine without any issue and shows message file.o is up to date however error is prompted at venting.o and venting

The code:

#declaring .PHONY rules
.PHONY: clean

#variable defined for -Wall -Wextra
CFLAGS=-Wall -Wextra

#rule to build the executable program venting from object file
venting: venting.o
    gcc $(CFLAGS) -o venting venting.o

#list objectable file is created with the following rules.
list.o: list.c list.h
    gcc $(CFLAGS) -c list.c

#list-adders objectable file is created with the following rules.
list-adders.o: list-adders.c list.h
    gcc $(CFLAGS) -c list-adders.c

#vents objectable file is created with the following rules.
vents.o: vents.c list.h vents.h
    gcc $(CFLAGS) -c vents.c

#venting.o objectable file is created with the following rules.
venting.o: list.o list-adders.o vents.o
    gcc $(CFLAGS) -c list.o list-adders.o vents.o

#rule to remove all build targets and rebuild project from the beginning.
clean:
    rm -f *.o venting

2 Answers 2

2
venting.o: list.o list-adders.o vents.o
    gcc $(CFLAGS) -c list.o list-adders.o vents.o

That is taking object files and passing it to gcc -c (i.e. compile only, no link). Since no linking is done, any input files that would only be passed to the linker are unprocessed here, so the frontend driver assumes that they were listed in error.

Sign up to request clarification or add additional context in comments.

Comments

0

When asking questions please provide the exact error output you got, rather than a paraphrased description. Also, please show the command that was invoked by make which gave you the error.

It's not possible to construct a "big" .o file from a bunch of other .o files. It's just not something compilers can do.

So this rule:

venting.o: list.o list-adders.o vents.o
     gcc $(CFLAGS) -c list.o list-adders.o vents.o

cannot work.

1 Comment

ld -r can do that, so in theory you could use gcc -Wl,-r -o venting.o list.o list-adders.o vents.o here -- but that's unlikely to be a supported use case and will run into issues with startup code and constructor resolution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.