This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GNU linker


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


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