This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cannot link ___assert, __impure_ptr with -mno-cygwin


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]