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: Error : Ld : cannot load '-lgcc' no such file or directory


Jon Thackray[SMTP:jont@harlequin.co.uk] wrote:
>Greg Maynard writes:
[snip]
> > properly ;).. Anyhow, when I run gcc it gives me the error 'Ld : cannot
> > load '-lgcc' no such file or directory' and I don't know where the heck
[snip]
>-lgcc means it is looking for libgcc.a. That can be found in
>gcc-lib/i386-cygwin32/cygnus-2.7.2-961023 (at least that's where it is
>for beta 17.1). The real question though, is why are you requiring
>libgcc.a at all? You might try nm libgcc.a to see if any of the
>symbols exported (those marked T or ?) are in your code.

Among other things libgcc.a contains __main, a function automatically
called at the beginning of any function called 'main' in your compiled
code. This function does some initialization, like calling do_ctors (or
something like that) to initialize the global C++ objects in your program
and so on. Some versions, perhaps all, also contain _alloca, which is
used to allocate large arrays (rather than taking them off the stack).

In short, the gcc library contains a number of calls made implicitly by
the compiler, and is usually included in any program you write. This is
why you don't need to link it explicitly: gcc will always link it for
you.

Now that you know where it is and why you need it; how do you get rid
of the error? Well, normally gcc (or ld, or someone) will search the
path mentioned above, at least if your GCC_EXEC_PREFIX is set correctly
(as indicated in the README file). If that environment variable wasn't
set correctly I would expect you to be getting the far more common
'cannot exec cpp' error. But perhaps you fixed that by moving cpp.exe
to the same directory as gcc (or somewhere else on your path)? Another
solution would be to put the directory containing libgcc.a in your
LIBRARY_PATH environment variable.

Hope this helps,
Colin.

-- Colin Peters - Saga Univ. Dept. of Information Science
-- colin@bird.fu.is.saga-u.ac.jp - finger for PGP public key
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/

-
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]