public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: gvaughan@oranda.demon.co.uk (Gary V. Vaughan)
To: John Mullee <jmullee@hotmail.com>
Cc: cygwin@sourceware.cygnus.com
Subject: Re: Making DLL's.
Date: Mon, 22 Mar 1999 08:56:00 -0000	[thread overview]
Message-ID: <uzp55lb0a.fsf@oranda.demon.co.uk> (raw)
In-Reply-To: John Mullee's message of "Mon, 22 Mar 1999 16:27:47 +0100"

John Mullee <jmullee@hotmail.com> writes:

> > That is I need to make sure that any data item that will be imported from a
> > dll has __attribute__((dllimport)), and any data item imported from a static
> > library cannot have this attribute.  Obviously, in a makefile driven build
> 
> Normally, in win32, this has to be specified manually - 
> with default being 'not exported'.
> RTFM for ".def" files:

Thanks for the reply, by this I know... perhaps a more concrete example:

I have two source files, lib.c and main.c, plus a header file lib.h.
I want to make a dll, `liblib.dll',  and an ar static archive, `liblib.a' from
the code in lib.c.  I will install both of these libraries plus the header
file, and can arrange for the linker to choose between the dll (for which I
will build an import library on the fly) and the static archive depending on
whether I ask for static linkage or not (gcc -static).

Obviously I need cpp to read lib.h when I build main.o (by adding #include
"lib.h").  I probably want cpp to read lib.h when I link lib.o (destined to be
included in liblib.a) and lib.lo (destined for liblib.dll) too, to get
function prototypes etc.

The difficult part is getting the correctly tagged declarations from the
header file to generate the correct assembly when I build main.lo (which I
will link against liblib.dll) and main.o (for liblib.a), otherwise I get
undefined _imp_foo errors at link time.

The really difficult part is designing a mechanism that allows someone else
to link liblib.dll or liblib.a by including lib.h...

The *really* difficult part is creating libdepend.h, whichdepends on
liblib.dll or liblib.a depending on whether I want to link a static executable
or not....

Is there a better solution to this than trying to find out the complete list
of libraries (and their types) against which each object will eventually be
linked so that I can tag data exports correctly when the asm code is
generated?

Cheers,
        Gary.
-- 
  ___              _   ___   __              _             
 / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___ 
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
 \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
PGP Key from/___/                      /___/               
http://www.cl.cam.ac.uk/PGP/pks-commands.html#extract      
http://pgp.ai.mit.edu/~bal/pks-commands.html#extract       


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

WARNING: multiple messages have this Message-ID
From: gvaughan@oranda.demon.co.uk (Gary V. Vaughan)
To: John Mullee <jmullee@hotmail.com>
Cc: cygwin@sourceware.cygnus.com
Subject: Re: Making DLL's.
Date: Wed, 31 Mar 1999 19:45:00 -0000	[thread overview]
Message-ID: <uzp55lb0a.fsf@oranda.demon.co.uk> (raw)
Message-ID: <19990331194500.56hmPQ0FBG8xo3tz_95f-0JMxJLb8w7WWKtUD-_Jor4@z> (raw)
In-Reply-To: <36F66173.1F71CC18@hotmail.com>

John Mullee <jmullee@hotmail.com> writes:

> > That is I need to make sure that any data item that will be imported from a
> > dll has __attribute__((dllimport)), and any data item imported from a static
> > library cannot have this attribute.  Obviously, in a makefile driven build
> 
> Normally, in win32, this has to be specified manually - 
> with default being 'not exported'.
> RTFM for ".def" files:

Thanks for the reply, by this I know... perhaps a more concrete example:

I have two source files, lib.c and main.c, plus a header file lib.h.
I want to make a dll, `liblib.dll',  and an ar static archive, `liblib.a' from
the code in lib.c.  I will install both of these libraries plus the header
file, and can arrange for the linker to choose between the dll (for which I
will build an import library on the fly) and the static archive depending on
whether I ask for static linkage or not (gcc -static).

Obviously I need cpp to read lib.h when I build main.o (by adding #include
"lib.h").  I probably want cpp to read lib.h when I link lib.o (destined to be
included in liblib.a) and lib.lo (destined for liblib.dll) too, to get
function prototypes etc.

The difficult part is getting the correctly tagged declarations from the
header file to generate the correct assembly when I build main.lo (which I
will link against liblib.dll) and main.o (for liblib.a), otherwise I get
undefined _imp_foo errors at link time.

The really difficult part is designing a mechanism that allows someone else
to link liblib.dll or liblib.a by including lib.h...

The *really* difficult part is creating libdepend.h, whichdepends on
liblib.dll or liblib.a depending on whether I want to link a static executable
or not....

Is there a better solution to this than trying to find out the complete list
of libraries (and their types) against which each object will eventually be
linked so that I can tag data exports correctly when the asm code is
generated?

Cheers,
        Gary.
-- 
  ___              _   ___   __              _             
 / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___ 
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
 \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
PGP Key from/___/                      /___/               
http://www.cl.cam.ac.uk/PGP/pks-commands.html#extract      
http://pgp.ai.mit.edu/~bal/pks-commands.html#extract       


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


  reply	other threads:[~1999-03-22  8:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-18 13:07 Serguei DACHIAN
1999-03-19  3:30 ` Paul Sokolovsky
1999-03-19  6:01   ` Sebastien Carpe
     [not found]     ` < 36F258AB.CC1A1788@atos-group.com >
1999-03-19  7:30       ` DJ Delorie
1999-03-22  2:32         ` Gary V. Vaughan
1999-03-22  7:28           ` John Mullee
1999-03-22  8:56             ` Gary V. Vaughan [this message]
1999-03-22 11:15               ` Re[2]: " Paul Sokolovsky
     [not found]                 ` < 3887.990322@is.lg.ua >
1999-03-22 22:25                   ` Mikey
1999-03-23  2:32                     ` Gary V. Vaughan
1999-03-31 19:45                       ` Gary V. Vaughan
1999-03-24  4:35                     ` Re[4]: " Paul Sokolovsky
1999-03-31 19:45                       ` Paul Sokolovsky
1999-03-31 19:45                     ` Re[2]: " Mikey
1999-03-23  1:13                 ` Gary V. Vaughan
1999-03-31 19:45                   ` Gary V. Vaughan
1999-03-31 19:45                 ` Paul Sokolovsky
1999-03-31 19:45               ` Gary V. Vaughan
1999-03-31 19:45             ` John Mullee
     [not found]           ` < u1zihvmrf.fsf@oranda.demon.co.uk >
1999-03-22 14:50             ` Fergus Henderson
1999-03-23  1:47               ` Gary V. Vaughan
1999-03-31 19:45                 ` Gary V. Vaughan
1999-03-31 19:45               ` Fergus Henderson
1999-03-31 19:45           ` Gary V. Vaughan
1999-03-31 19:45         ` DJ Delorie
1999-03-31 19:45     ` Sebastien Carpe
1999-03-31 19:45   ` Paul Sokolovsky
1999-03-31 19:45 ` Serguei DACHIAN
1999-03-21 15:04 Serguei DACHIAN
     [not found] ` < 1.5.4.32.19990321230358.00671530@lola.univ-lemans.fr >
1999-03-21 15:47   ` Mumit Khan
1999-03-31 19:45     ` Mumit Khan
1999-03-31 19:45 ` Serguei DACHIAN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uzp55lb0a.fsf@oranda.demon.co.uk \
    --to=gvaughan@oranda.demon.co.uk \
    --cc=cygwin@sourceware.cygnus.com \
    --cc=jmullee@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).