linker input file unused because linking not done - gcc

15,300

The culprit is the preprocessor option -MM. From gcc pre-processor options,

-M

Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.

Passing -M to the driver implies -E, and suppresses warnings with an implicit -w.

-MM

Like -M but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header.

So effectively you are just preprocessing and hence no compilation and no linking and the resultant error.

Share:
15,300
Mat
Author by

Mat

“Well!... That takes the biscuit!” Joyce, James. The Dubliners The best way to speed up something is to not do it in the first place. Kyte, Thomas.

Updated on November 22, 2022

Comments

  • Mat
    Mat over 1 year

    I am a beginner in writing makefiles. I have a makefile something like this:

    PATH1 = /ref
    
    CC=gcc
    LINK = gcc
    
    INCLUDES = .
    INCLUDES += -I/PATH1/inc \
            -I/$(PATH1)/abc/inc/ \
            -I/$(PATH1)/def/inc/ 
    
    
    all: src_file
    
    run: src_file
    
    src_file: 
        $(CC) $(INCLUDES) -MM  /ref/abcd.c -o $@ 
    
    clean:
        rm -f *.o src_file
    

    If I do a make, I get the error:

    linker input file unused because linking not done.
    

    I read some similar posts in stackoverflow but couldn't get a solution. Could anybody please let me know what's wrong with my makefile? Thanks in advance.

  • Admin
    Admin almost 12 years
    Thank you Pavan for the reply. That makes sense. Thanks for the link, will go through the various options.