delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/12/04/20:01:19

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20011205010031.91683.qmail@web14504.mail.yahoo.com>
Date: Wed, 5 Dec 2001 12:00:31 +1100 (EST)
From: =?iso-8859-1?q?Danny=20Smith?= <danny_r_smith_2001 AT yahoo DOT co DOT nz>
Subject: Re: Run time linking a .dll into a .exe
To: Glen Ozymok <ozymok AT hotmail DOT com>, cygwin AT cygwin DOT com
In-Reply-To: <F738XYwP1unNRL4dbnW0001d868@hotmail.com>
MIME-Version: 1.0

 --- Glen Ozymok <ozymok AT hotmail DOT 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
> routines.
> 
> 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
dllhelpers examples.

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

Danny

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
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019