This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Where are Reg* implemented?


Good point Jason about the ld man page. However, we are discuessing gcc 
or g++, not ld.

It is clear that we need to put the main() entry ( in one of the .c or 
.cxx files) as the first of the source file list ( including .o and .c). 
However, the libraries are not 'source files' to g++. Instead, they are 
assigned as 'options' by '-l'. Therefore, it is really the compiler's 
responsibility to add these options to correct position in parameter list 
passed to 'ld' later.

For example, for IBM AIX C compiler, you are only allowed to put 
parameters "before" the source file list: xlC [options] files
On the other hand, g++ allows two different syntex: g++ [option|filenam] ...

Anyway, why use same name in your own code as the name in libraries to 
confuse the linker ?

Sincerely,
Wei Ku

***************************************
Department of Physics and Astronomy
The University of Tennessee
1408 Circle Drive
Knoxville, Tennessee 37996-1200
weiku@utkux.utcc.utk.edu
---------------------------------------
Solid State Division
Oak Ridge National Laboratory
P.O.Box 2008
Oak Ridge, TN 37831-6032
Phone: (423) 574-5795
Fax: (423) 574-4143
weiku@solid.ssd.ornl.gov
***************************************

On Fri, 1 Aug 1997, Jason Zions wrote:

> > My impression ( an what I always do ) is to put the options before the
> > files to be compiled or linked as following:
> > 
> > g++ -o outfilename -O -L libpath -l lib file.c file.o ...
> 
> Usually won't work. *Most* options need to go up front; -O, -L, etc.
> 
> Library options (-l) *must* be specified in the *correct order* so that
> resolution can be controlled. By listing a library, -lfoo, before any .o
> files have been loaded, you're trying to resolve entrypoints from the
> library before the loader has seen any unresolved names.
> 
> First list the .o files, then the libraries you want the loader to use
> to resolve entrypoints, in the order you want it to try. If two
> libraries both have a particular entrypoint, the first one the loader
> sees (once it sees the unresolved name from another file) is the one it
> loads, and it silently ignores the latter one (because the name has
> already been resolved).
> 
> This is basic stuff, folks. Read a Unix system's "ld" man page.
> 
> Jason
> 
> 
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]