Criteria for GCC 4.0 [auto-locating libraries]

Per Bothner per@bothner.com
Wed Jun 2 06:51:00 GMT 2004


Theodore Papadopoulo wrote:

> I really think that the best way to do this is for the compiler to 
> produce .o files that somehow contain the gcc library requirements.
> Then any gcc driver used to link the files together should collect 
> these libraries and add them to the linker command line.
> ...
> Remember that this is only for gcc's internal libraries,

Actually, I think it should be supported for user libraries too.
Remember that bad old days when you had to specify -lm if you
used a math function?  Well, we still have the same problem,
but worse.  For C, C++, and Java libraries (which are already in a
global namespace), prorammers are requires to know the magic -l
incantation to add.  This is ridiculous.

For Java, if class A references class B, the compiler needs to be
able to find class B when compling class A.  So the compiler needs
to remember the library where it found B, and include that information
in A.o.

For C and C++, a header file foo.h could include a __Pragma that
would enable the linker to find the library containing foo.o.

I'm talking about defaults - if should be possible to specify to
linker that it should use some other library that it was compiled
against - but most users should not need to add -l or -L flags.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Gcc mailing list