This is the mail archive of the email@example.com
mailing list for the Cygwin project. See the Cygwin
home page for more information.
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]
Re: Making DLL's.
John Mullee <firstname.lastname@example.org> 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
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
___ _ ___ __ _
/ __|__ _ _ ___ _| | / / | / /_ _ _ _ __ _| |_ __ _ ___
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
\___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
PGP Key from/___/ /___/
Want to unsubscribe from this list?
Send a message to email@example.com