jesusjimsa
jesusjimsa

Reputation: 405

clang: warning: principal.o: 'linker' input unused

I'm studying computer engineering and I'm trying to compile an exercise but I get the warning in the title of the question

clang: warning: principal.o: 'linker' input unused

I think it is a problem in my Makefile but I'm not able to find it. Here is my Makefile

CPPFLAGS = g++ -c

principal : principal.o 
    $(CPPFLAGS) principal.o -o principal

principal.o: principal.cpp conjunto.o
    $(CPPFLAGS) principal.cpp -o principal.o -I.

enfermedad.o: enfermedad.cpp
    $(CPPFLAGS) enfermedad.cpp -o enfermedad.o -I.

mutacion.o: mutacion.cpp enfermedad.o
    $(CPPFLAGS) mutacion.cpp -o mutacion.o -I.

conjunto.o: conjunto.cpp mutacion.o
    $(CPPFLAGS) conjunto.cpp -o conjunto.o -I.

clean:
    echo "Cleaning..."
    rm *.o

Thanks a lot for those who answer.

Upvotes: 1

Views: 3408

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753455

Using CPPFLAGS to specify both the compiler and the flags is aconventional at best; you'd do better to separate them.

A minimal fix to your makefile is:

principal : principal.o 
    g++ principal.o -o principal

This avoids including the -c option when intending to link the program. However, you probably need to list all the object files in the link command line. Your dependency structure is a little unusual too, though not formally wrong.

A more plausible fix, therefore, is:

OBJECTS = principal.o enfermedad.o mutacion.o conjunto.o 

principal: ${OBJECTS} 
    g++ ${OBJECTS} -o $@

Upvotes: 3

Related Questions