This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: error message : linker input file unused since linking not done
- To: "Thomas Singleton [Eidos]" <singleton at skynet dot be>
- Subject: Re: error message : linker input file unused since linking not done
- From: "Peter A. Friend" <octavian at corp dot earthlink dot net>
- Date: Sat, 25 Dec 1999 23:43:22 -0800 (PST)
- cc: help-gcc at gnu dot org
On Sat, 25 Dec 1999, Peter A. Friend wrote:
>
> On Sun, 26 Dec 1999, Thomas Singleton [Eidos] wrote:
>
> > hello,
> > in order to follow a book's test procedure to see if the compiling/linking
> > of C programs work, i created a hello.c
> > file with the famous 'printf("Hello World!");' then (always following the
> > instructions) did :
> > $gcc -c -Wall -D_GNU_SOURCE hello.c -o hello.o
> > then
> > $gcc -c hello.o hello.c
> > which reported :
> > gcc: hello.o : linker input file unused since linking not done
> >
> > i made a search for that message on gcc.gnu.org, and found a few linked
> > messages but they were all about merging two or more source into the same
> > object which is not my case, so i decided to post this
>
> The message that gcc reported is correct. When you supply a library
> (even a compiled object file like you did) to a command that does no
> linking (gcc -c), gcc simply informs you that the library was not used
> because no linking was done. You didn't ask it to. Since you specified
> -c, "source" files are going to be compiled into .o object files, NOT into
> an executable, nor is anything going to be done with any object files. Gcc
> saw the extraneous object file supplied and simply ignored it.
Sorry, I forgot to mention something actually helpful. ;-) What you
probably want to do as the last step is:
gcc -o hello hello.o
or something similar. If those commands were typed verbatim out of the
book, then the book has an error in it. Note that this is simply a long
winded version of:
gcc -o hello hello.c
Which does the same thing.
Peter