delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/28/22:14:45

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
Message-ID: <e2439468050328191472500340@mail.gmail.com>
Date: Mon, 28 Mar 2005 19:14:22 -0800
From: Matt Olson <matt DOT j DOT olson AT gmail DOT com>
Reply-To: Matt Olson <matt DOT j DOT olson AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Cannot link ___assert, __impure_ptr with -mno-cygwin
Mime-Version: 1.0
X-IsSubscribed: yes

Hello,

I'm trying to port some SDL code from Linux to Win32-Cygwin, and I've
run into problems linking programs using assert() and fprintf() with
the -mno-cygwin flag.  (I'm compiling and linking with -mno-cygwin
because that's what the output of `sdl-config --libs` gives me.)  I've
Googled, with little success, on the "undefined reference to
`___assert'" message, and the only documentation I can find on
-mno-cygwin is this entry from the MinGW FAQ:

http://www.mingw.org/mingwfaq.shtml#faq-usingwithcygwin
"For those who would like to use the Cygwin environment for
development, yet generate non-Cygwin-dependant executables, a much
easier option to "-mno-cygwin" does exist. [...]"
(That's the only mention of -mno-cygwin on the page.)

I've narrowed my problems down to a relatively small test case:

foo.c:
#include <assert.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
        fprintf(stdout, "Trying to assert\n");
        assert(argc > 0);
        return 0;
}

Makefile:
# Let's try to be BSD Make compatible
.SUFFIXES : .o .c .test


COMPFLAGS = -Wall -ansi -g -mwindows -mno-cygwin
LINKFLAGS = -g -L/lib/mingw -mwindows -mno-cygwin
LIBS      = -lmingw32

foo: foo.o
        gcc $(LINKFLAGS) -o foo foo.o $(LIBS)

.c.o :
        gcc $(COMPFLAGS) -c $<

Compiler output:
$ make
gcc -g -L. -L/home/matt/lib -L/lib/mingw -o foo foo.o -lmingw32
-mwindows -mno-cygwin
foo.o(.text+0x27): In function `main':
/home/matt/devel/scratch/foo.c:6: undefined reference to `__impure_ptr'
foo.o(.text+0x54):/home/matt/devel/scratch/foo.c:7: undefined
reference to `___assert'
collect2: ld returned 1 exit status
make: *** [foo] Error 1


I've installed the gcc, gcc-core, gcc-g++, gcc-mingw, gcc-mingw-core,
and gcc-mingw-g++ packages, as well as binutils (and various others).

Any advice?

Thanks,
--Matt

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.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