Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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?= Subject: Re: Run time linking a .dll into a .exe To: Glen Ozymok , cygwin AT cygwin DOT com In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit --- Glen Ozymok 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/