linker input file unused since linking not done

Peter A. Friend octavian@corp.earthlink.net
Fri Oct 1 00:00:00 GMT 1999


On Wed, 29 Sep 1999 amyyon@my-deja.com wrote:

> Hi,
> 
> I have created 2 C-files which I want to compile.
> Normally I would do:
> cc -c file1.c
> cc -c file2.c file1.o
> This works fine with a Solaris C compiler,
> however, it gives me an error message with the
> GNU compiler:
> linker input file unused since linking not done
> 
> I have tried to add the -L option:
> cc -c file2.c -Lfile1.o
> It it gives me no error message, but when I run
> my program (which would link file1 and file2) it
> can not find the functions I have defined.
> 
> After reading a lot of man-pages I am not able to
> get this fixed.
> Anyone?

This is normal behavior. Since you specified the -c switch, all that is
being done is the compilation of the .c code into an object file. The
linker is not called, because you told gcc NOT to call the linker, hence,
the library is "unused". Note that things will work if you do the same
thing but make your next step:

gcc file2.o file1.o

This actually calls the linker and places the executable in a.out.

The common procedure is to use -c to create all of your object files
(without the libraries specified), then calling gcc with only the object
files and the libraries later. This makes sense when you realize that
gcc does NOT need the library to do the compilation.

Peter


---
Software Engineer
EarthLink Network



More information about the Gcc-help mailing list