Run time linking a .dll into a .exe
Tue Dec 4 18:21:00 GMT 2001
--- Glen Ozymok <email@example.com> wrote: > I want to create some
plugins for an executable.
> The problem is that when I create a plugin
> (.dll, shared object, or whatever you want to call it),
> it sucks in code that is already in the executable.
> In other words, I link the executable with some static
> library, libfoo.a, and the executable gets routines from
> libfoo.a. I then link the dll, and it gets some of the same
> Normally this would be annoying since you have code
> duplication, but would work. However, if the code
> contains static variables, then the executable and the
> dll have their own versions of the static, which get out
> of sync.
> Is there a way to link the dll so that it uses the code
> inside the executable?
The safest way is to make libfoo.a into a dll. and link against that to get
your static variable. That way there is one and only one copy of the
variable, living in the dll. See the C++ code in a recent version of the
BTW, a very similar problem occurs when throwing exceptions across dll/exe
boundaries when the eh code lives in a static lib (say libgcc.a).
http://shopping.yahoo.com.au - Yahoo! Shopping
- Get organised for Christmas early this year!
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
More information about the Cygwin