Subject: RE: Error : Ld : cannot load '-lgcc' no such file or directory
From: [email-masked] (Colin Peters)

10 Aug 1997 20:34:32 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BCA64B.6F15F800.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Original-To: "[email-masked]" <[email-masked]>
Original-Sender: [email-masked]

Jon Thackray[SMTP:[email-masked]] 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
-- [email-masked] - 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
"[email-masked]" with one line of text: "help".