<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/1.1.7">
</HEAD>
<BODY>
One problem is that 'myglobal' is a pointer to an int, but the int is never defined, and hence, you're assigning a value to a pointer that points no where.<BR>
<BR>
It's very common for things like this to work on one platform, but not another.<BR>
<BR>
On Sat, 2003-02-22 at 00:21, Steve Baldwin wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#050c87" SIZE="3"><I>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 <stdio.h>
#include <stdlib.h>
extern void fx (void) ;
extern int myglobal ;
int
main (int argc, char **argv) {
myglobal = 99 ;
fx () ;
}
[cdev]$ cat b.c
#include <stdio.h>
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: </FONT><A HREF="http://cygwin.com/ml/#unsubscribe-simple"><FONT SIZE="3">http://cygwin.com/ml/#unsubscribe-simple</FONT></A>
<FONT COLOR="#050c87" SIZE="3">Bug reporting: </FONT><A HREF="http://cygwin.com/bugs.html"><FONT SIZE="3">http://cygwin.com/bugs.html</FONT></A>
<FONT COLOR="#050c87" SIZE="3">Documentation: </FONT><A HREF="http://cygwin.com/docs.html"><FONT SIZE="3">http://cygwin.com/docs.html</FONT></A>
<FONT COLOR="#050c87" SIZE="3">FAQ: </FONT><A HREF="http://cygwin.com/faq/"><FONT SIZE="3">http://cygwin.com/faq/</I></FONT></A></PRE>
</BLOCKQUOTE>
<PRE><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>--
David Means
Different all twisty a of in maze are you, passages little.</PRE>
</TD>
</TR>
</TABLE>
</PRE>
</BODY>
</HTML>