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 From: Jason Moxham Message-Id: <200108200319.EAA03624@malus.maths.soton.ac.uk> Subject: Re: dll-helpers To: cygwin AT cygwin DOT com Date: Mon, 20 Aug 2001 04:19:32 +0100 (BST) In-Reply-To: <3B7FF33A.8000104@ece.gatech.edu> from "Charles Wilson" at Aug 19, 2001 01:11:22 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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. Sorry , I didn't send it to cygwin list as I wrongly assumed that it wasnt a cygwin specific question , just a gcc+windows question and as your site has this type of thing... anyway , thanks > > 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. ARGHHHHH!!!! I should of checked before I started programming , windows has so many arbitary limitations , I dread the day when I have to change to a multi-threaded version of my program > 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. > Thanks , I can use either of these methods , although the first seems easier Jason Moxham j DOT l DOT moxham AT maths DOT soton DOT ac DOT uk > 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/ > > -- 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/