public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GNU linker
@ 2002-02-18  4:31 Bård Lutzow-Holm Myrstad
  0 siblings, 0 replies; 2+ messages in thread
From: Bård Lutzow-Holm Myrstad @ 2002-02-18  4:31 UTC (permalink / raw)
  To: gcc

How do ld know which library to load for an application?

Many applications using sockets run the socket-code from libc,
but if the application is using pthreads, it will need to use
the socket-calls in libpthread. How does ld know which library to
choose?

Bård Myrstad

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GNU linker
@ 2002-02-18 12:13 Arun Saini , Gurgaon
  0 siblings, 0 replies; 2+ messages in thread
From: Arun Saini , Gurgaon @ 2002-02-18 12:13 UTC (permalink / raw)
  To: baardm; +Cc: gcc

>How do ld know which library to load for an application?

It doesn't. It searches for undefined symbols in libraries specified to it,
in the order in which they are specified (searching iteratively if
required).

>Many applications using sockets run the socket-code from libc,
>but if the application is using pthreads, it will need to use
>the socket-calls in libpthread. How does ld know which library to
>choose?

Specify -lpthread on the command line while linking the executable. Actually
you need to place it before -lc which if not specified explicitly occurs
after the user specified libraries in the search order.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-02-18 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-18  4:31 GNU linker Bård Lutzow-Holm Myrstad
2002-02-18 12:13 Arun Saini , Gurgaon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).