Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <3B7FF33A.8000104@ece.gatech.edu> Date: Sun, 19 Aug 2001 13:11:22 -0400 From: Charles Wilson Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010713 X-Accept-Language: en-us MIME-Version: 1.0 To: Jason Moxham , cygwin AT cygwin DOT com Subject: Re: dll-helpers References: <200108191350 DOT OAA03236 AT malus DOT maths DOT soton DOT ac DOT uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit This is really a "how to build dll's" question and belongs on the cygwin list, not private mail. For your convenience, I've copied this message to the list and set the Reply-To; appropriately. Jason Moxham wrote: > Using the latest cygwin I can compile and run the "c" version of > dllhelpers-0.2.7 , but what I'm having trouble with is , if my dll > contains referances to varibles/fns in the main exe or another dll > then I get undefined referances when I try to compile my dll Right. you can't do that on windows. DLLs (unlike unix shared libraries) are not allowed to have any unresolved symbols. Thus, you can't have forward references from the DLL to a client executable. There are two ways to proceed: 1) put the "common" data items in a second DLL that can be built independently of the first DLL and the executable. Then, when building the original DLL, link against this second one. When building the executable, link against both DLLs. or 2) Create hook functions in your DLL to set a DLL-internal pointer to point to your exe's variable. Within the DLL, only use the pointer in your operations. e.g. DLL: int * ext_data; void set_ext_data(int * c) {ext_data = c}; In dll, use *ext_data. client exe: int data; set_ext_data(&data); in client, use data. --Chuck > > for example > > add to usedll.c (not in main fn) > > int jayglob; > > > > add to cdll.c > > int jay(void){return jayglob;} > > > add to cdll.h > > int jay(void); > extern int jayglob; > > > then when I try to compile cygcdll.dll I get undefined referances to > jayglob > > > > Of course under linux , no problems -- 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/