From: b DOT dautrevaux AT usa DOT net (Bernard DAUTREVAUX) Subject: RE: Which way to compile and link for mingw32 and iostreams 4 Dec 1998 12:48:29 -0800 Message-ID: <01BE1F78.DAAB2B60.b.dautrevaux.cygnus.gnu-win32@usa.net> Reply-To: "b DOT dautrevaux AT usa DOT net" To: "'thanny AT home DOT com'" , "GnuWin32 Mailing list (Adresse de messagerie)" > ------------------------------------------------------------------------------ > > Bernard Dautrevaux > Microprocess Ingéniérie > 97 bis, rue de Colombes > 92400 COURBEVOIE > FRANCE > Tel: +33 (0) 1 47 68 80 80 > Fax: +33 (0) 1 47 88 97 85 > e-mail: b. dautrevaux AT usa DOT net > ------------------------------------------------------------------------------ > > > > -----Original Message----- > From: thanny AT home DOT com [SMTP:thanny AT home DOT com] > Sent: Thursday, December 03, 1998 02:22 > To: gnu-win32 AT cygnus DOT com > Subject: Which way to compile and link for mingw32 and iostreams > > I'm attempting to compile my C++ program into a Win32 console executable > (already have DOS, DPMI, and OS/2 done), and have run into something of a > snag. > > I need to use the following non-standard C library functions: > > _kbhit() > _getch() > _strrev() > _itoa() > > I also want the executable to be independant of any Cygwin files. > > If I compile with -mno-cygwin, then __CYGWIN__ isn't defined, and the > preprocessor doesn't include the headers in the mingw32 directory. > Yes, but the problem is not here; the problem is that mingw32 should be included in the CPP search path before the standard include directory (as some header files are present in both directories and you definitely need the one in mingw32 if it exist). To correct this I change a bit the specs file (see the version I join below). In this specs file I also add a "-use-msvcrt" flag that allows you to use MSVCRT40 instead of the (brain-dead) CRTDLL, taht amongs other shortcomings insist on limiting the total size of args+environment passed to a subprocess to 1024 bytes!... > If I compile without it, using the headers in the mingw32 directory, I run > into problems linking with the -mno-cygwin switch. Specifically, > undefined references, such as this: > > /libstdc++.a(iostream.o)(.text+0x113):iostream.cc: undefined reference to > `_ctype_' /libstdc++.a(iostream.o)(.text+0x195d):iostream.cc: undefined > reference to `_impure_ptr' > /libstdc++.a(streambuf.o)(.text+0x34c):streambuf.cc: undefined reference > to `__errno' /libstdc++.a(stdiostream.o)(.text+0x14e):stdiostream.cc: > undefined reference to `__srget' collect2: ld returned 1 exit status > > I snipped the path information from the front, and only included one of > each error, from multiple instances. > I got into exactly the same link problems;I also have a problem with finding "__errno" in libm.a... __errno is (I think, anyone correct me if I'm wrong) defined by cygwin, but on mingw32 I think we have "_errno", so I think we need either a corrected mingw32.a and mingw32/errno.h (at least for the errno problem, but I hope this is similar for the others) or a version of libstdc++.a/libm.a (and probably others) compiled for mingw32, and not for cygwin... > So, how do I compile and link with the mingw32 libraries, without breaking > iostreams? > > My feeling is that I need to compile with the -mno-cygwin switch, and if > that's the case, I need to know which define to check for the Cygwin > compiler, so that I include the mingw32 headers instead of the standard > ones. > There is a __MINGW32__ flag defined by the standard specs, but you need either to explicitely read from the mingw32 subdirectory for some include files or use my patch below that compiles OK but still cause link problems. Here is the patched specs file (from ..../cygwin-B20/lib/gcc-lib/i586-cygwin32/egcs-2.91.57/specs); I think this could be interesting for others (both the correction in cpp_specs to add mingw32 in the cpp search path and the -use-msvcrt flag, that would probably better named -mmsvcrt but this needs a gcc modification otherwise cc1 will complain about an undefined flag). Hope this helps a bit, Bernard begin 600 specs M*F%S;3H*"@HJ87-M7V9I;F%L DOT AT H*"BIC<' Z"BUR96UA<" E*&-P<%]C<'4I M("5[<&]S:7 AT Z+41?4$]325A?4T]54D-%?2 E>R%M;F\M8WEG=VEN.BU$7U]# M64=724XS,E]?("U$7U]#64=724Y?7WT@)7MM;F\M8WEG=VEN.BUI=VET:'!R M969I>&)E9F]R92 N+B\N+B\N+B\N+B]I-3 AT V+6-Y9W=I;C,R+VEN8VQU9&4O M;6EN9WW5S92UMVUD;&PZ+2UD;&P@+64 AT 7T1L;$UA:6Y#4E13 M=&%R='5P0#$R?2 *"BIL:6(Z"B5[<&R%M;F\M8WEG=VEN M.BUL8WEG=VEN?2 E>VUW:6YD;W=S.BUL=7-ER%M9&QL.B E>R%M;F\M8WEG=VEN.F-R=# E3R5S?2 E>VUN;RUC>6=W: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