This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: helpful hints to build dlls in Win32 using cygwin (gnu)
- To: gnu-win32 at cygnus dot com
- Subject: Re: helpful hints to build dlls in Win32 using cygwin (gnu)
- From: Fergus Henderson <fjh at cs dot mu dot OZ dot AU>
- Date: Fri, 1 Aug 1997 14:56:37 +1000 (EST)
- References: <33E0F327.DF8B81B3@Eng.Sun.COM>
Padmakar Vishnubhatt <padmakar@eng.sun.com> writes:
>I did exactly as u recommended in your hints - and yet I get the
>following error when I run the linker (ld). Am I missing something in
>the cygwin distribution?
>
>/gnuwin32/b18/H-i386-cygwin32/i386-cygwin32/lib/libcygwin.a(libccrt0.o)(.text+0x
>8a):libccrt0.cc: undefined reference to `GetModuleHandleA@4'
Your problem is due to `_impure_ptr'. (By the way, to debug these
sorts of problems, use the `-Map' and `--cref' options to `ld'.)
libccrt0.o should not be linked in to DLLs at all.
The reason that it does get linked in is because it defines `_impure_ptr',
which is referenced by your code (implicitly, e.g. because stdout
is #defined as `_impure_ptr._stdout'), and which is
not defined anywhere else.
You need to provide a definition of `_impure_ptr'.
You also need to initialize it (otherwise references to stdout
etc. in your DLL will be bogus).
For example:
/* impure.c -- link this into your libfoo.dll */
void *_impure_ptr;
void *libfoo_impure_ptr_ptr = &_impure_ptr_ptr;
/* main.c -- link this into the program that uses the DLL */
int main() {
(*_imp_libfoo_impure_ptr_ptr) = _impure_ptr_ptr;
...
}
No doubt this is fairly confusing.
I am currently in the process of getting Mercury to use DLLs
on gnu-win32. I have packaged up a neat solution to the problem
of global variables in DLLs. See <http://www.cs.mu.oz.au/~fjh/gnu-win32>.
I also have a solution to this problem with `_impure_ptr',
but it's not yet on my WWW page (I'm still testing it).
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".