public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* ld -shared
@ 2000-05-26  5:46 Jon Cook
  2000-05-26  9:32 ` DJ Delorie
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Cook @ 2000-05-26  5:46 UTC (permalink / raw)
  To: cygwin

Hi,

Is the -shared option to ld supported?. 

I know it was not under version beta 20.1 (ld said so if you tried
using it) and this feature was listed in the TODO list. I've now
installed the net release and ld no longer complains and the
corresponding TODO list entry has disappeared.

While this leads me to belive it is supported, I'm having problems
using it. Essentially what I have, in a file a.c, is:

void b(void);

void a(void)
{
   b();
}

On a Unix box I can create a shared library with:

gcc -c a.c
ld -shared a.o -o liba.so

But when I try this on cygwin I get an unresolved reference to b -
exactly as if the shared option is ignored.

Thanks for any help,
Jon



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* Re: ld -shared
  2000-05-26  5:46 ld -shared Jon Cook
@ 2000-05-26  9:32 ` DJ Delorie
  2000-05-26 10:14   ` Jon Cook
  0 siblings, 1 reply; 4+ messages in thread
From: DJ Delorie @ 2000-05-26  9:32 UTC (permalink / raw)
  To: cookj; +Cc: cygwin

> Is the -shared option to ld supported?. 

Yes, but it creates DLLs not shared libraries.

> ld -shared a.o -o liba.so
> 
> But when I try this on cygwin I get an unresolved reference to b -
> exactly as if the shared option is ignored.

You have to link against an import library that defines where b comes
from.  DLLs work differently than shared libraries.  You'll end up with
something like this:

  ld -shared a.o libb.a -o a.dll

where libb.a is the import library for, say, b.dll

Try "ld --help" for a full list of options; the DLL-specific ones are
at the end.  --out-implib and --export-all-symbols will probably be
useful to you.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* Re: ld -shared
  2000-05-26  9:32 ` DJ Delorie
@ 2000-05-26 10:14   ` Jon Cook
  2000-05-26 11:16     ` DJ Delorie
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Cook @ 2000-05-26 10:14 UTC (permalink / raw)
  To: dj; +Cc: cygwin

>> "DJ" == DJ Delorie <dj@delorie.com> writes:

Thanks for your response.

DJ> You have to link against an import library that defines where b
DJ> comes from.  DLLs work differently than shared libraries.  

Is there any plans to make them work in the same way as shared
libraries on a Unix machine (I dont know if this is possible or even
desirable!). 

I've played around with creating DLLs using import libraries, but I'm
not sure if they will work for my situation.

I have 3 libraries: a base library, A, and two extra ones, B and C,
which add extra functionality to A. B and C are independent to each
other, but both reference A.

For some applications I link solely with A, but other applications
are linked against one or both of B and C plus the base library
A (this is linking under Unix). Hope this make sense!

Making a DLL for A is straight forwards. DLLs for B and C are also
easy to create in isolation, they both use A's import library.

I can see how linking an application against either A, B or C will
work (B and C should automatically include A and so I would not need
to link explicitly against this). But, can I link an application
against both B *and* C without causing a problem since A will now be
included twice.

Thanks for you help.

Cheers,
Jon

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* Re: ld -shared
  2000-05-26 10:14   ` Jon Cook
@ 2000-05-26 11:16     ` DJ Delorie
  0 siblings, 0 replies; 4+ messages in thread
From: DJ Delorie @ 2000-05-26 11:16 UTC (permalink / raw)
  To: cookj; +Cc: cygwin

> Is there any plans to make them work in the same way as shared
> libraries on a Unix machine (I dont know if this is possible or even
> desirable!). 

Possible, yes, but not practical.  Windows already has a mechanism
(dlls) so the gains aren't worth the effort.  If you want real shared
libraries, get Interix, which runs on the posix side of NT, or get
Linux.

> I can see how linking an application against either A, B or C will
> work (B and C should automatically include A and so I would not need
> to link explicitly against this). But, can I link an application
> against both B *and* C without causing a problem since A will now be
> included twice.

Yes.  Windows resolves those issues when it loads the DLLs.  Your
program doesn't even need to know that B and C use A, since it only
sees the import libraries, not the whole DLL's objects.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

end of thread, other threads:[~2000-05-26 11:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-26  5:46 ld -shared Jon Cook
2000-05-26  9:32 ` DJ Delorie
2000-05-26 10:14   ` Jon Cook
2000-05-26 11:16     ` DJ Delorie

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