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 Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Steve Baldwin" To: Subject: RE: Accessing global variables causes segfault - SOLVED Date: Sat, 22 Feb 2003 18:02:49 +1100 Message-ID: <000801c2da40$69d8c050$3264a8c0@AUSTBMOBILE> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal In-Reply-To: <000701c2da32$4472f640$3264a8c0@AUSTBMOBILE> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 OK, I think I've solved this by creating export/import libraries. Thanks -----Original Message----- From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of Steve Baldwin Sent: Saturday, 22 February 2003 4:22 PM To: cygwin AT cygwin DOT com Subject: Accessing global variables causes segfault I'm having some (further) issues porting some Unix code to cygwin. I have a scenario where there are global variables defined in a shared library, and referenced in the executable. See the example below. Yes I know it's bad coding practice, but I'm hoping to port the code with the least amount of re-writing as possible. It works fine under Unix, but as you can see from below, doesn't play well under cygwin. Is there anything I can do - apart from the obvious re-write. Cheers, Steve [cdev]$ cat a.c #include #include extern void fx (void) ; extern int myglobal ; int main (int argc, char **argv) { myglobal = 99 ; fx () ; } [cdev]$ cat b.c #include int *myglobal ; void fx (void) { printf("here i am : myglobal = %d\n", myglobal) ; } [cdev]$ gcc b.c -o libb.dll -shared [cdev]$ gcc a.c -o a -L. -lb [cdev]$ a Segmentation fault (core dumped) -- 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/