delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/24/12:35:55

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 24 Nov 2002 09:33:28 -0800 (PST)
From: "Peter A. Castro" <doctor AT fruitbat DOT org>
To: Andrew DeFaria <ADeFaria AT SALIRA DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: impure_ptr/Mingw and Cygwin
In-Reply-To: <3DDF2CA0.2030104@Salira.com>
Message-ID: <Pine.LNX.4.21.0211240931120.7231-100000@gremlin.fruitbat.org>
MIME-Version: 1.0
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id gAOHZsI18866

On Fri, 22 Nov 2002, Andrew DeFaria wrote:

> Peter A. Castro wrote:
>       On Fri, 22 Nov 2002, Andrew DeFaria wrote:
> 
>             I wish to use -mno-cygwin to produce an
>             executable that can work without Cygwin
>             installed. I have successfully done this before.
>             Now I'm adding some functionality to my program
>             and it is no longer working! I've worked it out
>             such that it will compile and link but when my
>             program runs it simply stops returning an exit
>             code of 5. Running this under gdb produces a
>             SIGSIGV Segmentation fault then you attempt to
>             run it.
> 
>             I've whittled it down to the bare minimum to
>             reproduce the problem.  Seems to me the problem
>             is somewhere between newer versions of gcc 3.X
>              and Mingw.
> 
>             File: foo.c:
> 
>             #include <stdio.h>
>             int main (void) {
>             printf ("Hello World\n");
>             fprintf (stderr, "%s\n", "Hello World 2");
>             }
> 
>             $ gcc -g foo.c -mno-cygwin -I/usr/include -o foo
>             -liberty -lcrtdll -lg
>             $ foo
>             $
> 
>             Note that if I do not put -lg then I get:
> 
>             /tmp/ccKAyr4S.o(.text+0x4b): In function `main':
>             /dview/defaria_2.0/salira/neopon/build/maketools/foo.c:4:
>             undefined
>             reference to `_impure_ptr'
> 
>             Any ideas?
> 
>       Well, for one thing, linking with -lg will pull in cygwin.dll
>       since /lib/libg.a is a symlink to libcygwin.a. So your
>       program won't be Cygwin-free, if that's your goal.
> 
> Hey I didn't know that. I saw undefined references to _impure_ptr and
> looked for where it was defined and wham, libg.a came up.
>       However, I got it to work with the following command:
> 
>       $ gcc -g foo.c -mno-cygwin -mwindows -o foo -liberty
>       -lmingw32
>       $ ./foo.exe > x
>       $ cat x
>       Hello World
> 
> Thanks. I got this contrived example foo.c to work to. However pluging
> these values into my real world problem still fails:

What you show below is only linking.  I believe you need to re-compile
all of your source with -mno-cygwin -mwindows as well to make the
_impure_ptr references go away.

> /bin/gcc mksf.o mksfOpts.o mksfIO.o flmCrc.o -mno-cygwin -mwindows
> -liberty -lmingw32 -o mksf
> mksf.o(.text+0x60f): In function `main':
> /dview/defaria_2.0/salira/neopon/build/maketools/mksf.c:29: undefined
> reference to `_impure_ptr'
> mksf.o(.text+0x874):/dview/defaria_2.0/salira/neopon/build/maketools/mksf.c:66:
> undefined reference to `_impure_ptr'
> mksfOpts.o(.text+0x309): In function `usage':
> /dview/defaria_2.0/salira/neopon/build/maketools/mksfOpts.c:13: undefined
> reference to `_impure_ptr'
> mksfOpts.o(.text+0x331):/dview/defaria_2.0/salira/neopon/build/maketools/mksfOp
> s.c:14: undefined reference to `_impure_ptr'
> mksfOpts.o(.text+0x352):/dview/defaria_2.0/salira/neopon/build/maketools/mksfOp
> s.c:15: undefined reference to `_impure_ptr'
> mksfOpts.o(.text+0x36a):/dview/defaria_2.0/salira/neopon/build/maketools/mksfOp
> s.c:16: more undefined references to `_impure_ptr' follow
> make: *** [mksf] Error 1
> 
> Again the _impure_ptr things come up. Where is this supposed to be
> resolved from?
> 
> --
>                                      Salira
>                           Ethernet Simple, Fiber Fast
> 
> 5451 Patrick Henry Drive
> Santa Clara, CA 95054
> Phone: (408)-845-5321
> Fax: (408)-845-5205
> Email: ADeFaria AT Salira DOT com
> Web: http://www.salira.com
> 
>                                Instant Messaging
> AIM:
> defaria
> MSN:
> Andrew AT DeFaria DOT com
> Yahoo:
> andrew_defaria
> ICQ #:
> 23552673
> 
> Andrew DeFaria
> Clearcase Administrator
> Email: Andrew AT DeFaria DOT com
> Web: http://DeFaria.com


-- 
Peter A. Castro <doctor AT fruitbat DOT org> or <Peter DOT Castro AT oracle DOT com>
	"Cats are just autistic Dogs" -- Dr. Tony Attwood


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019