This is the mail archive of the cygwin@sourceware.cygnus.com 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]

RE: Which way to compile and link for mingw32 and iostreams


> 
------------------------------------------------------------------------------
>
> 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@usa.net
> 
------------------------------------------------------------------------------
>
>
>
> -----Original Message-----
> From:	thanny@home.com [SMTP:thanny@home.com]
> Sent:	Thursday, December 03, 1998 02:22
> To:	gnu-win32@cygnus.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.@H*"BIC<' Z"BUR96UA<" E*&-P<%]C<'4I
M("5[<&]S:7@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@V+6-Y9W=I;C,R+VEN8VQU9&4O
M;6EN9W<S,B M1%]?34E.1U<S,E]?/3 N,B E>W5S92UM<W9C<G0Z+41?7TU3
M5D-25%]??7T*"BIC8S$Z"B4H8V,Q7W-P96,I("5[=7-E+6US=F-R=#I]"@HJ
M8V,Q<&QU<SH*"@HJ96YD9FEL93H*"@HJ;&EN:SH*)7MM=V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X
M-GT@)7MM;F\M-#@V.BUM8W!U/6DS.#8@+6UA<F-H/6DS.#9]("5[;30X-CHM
M;6-P=3UI-#@V("UM87)C:#UI-#@V?2 E>VUN;RTS.#8Z+6UC<'4]:30X-B M
M;6%R8V@]:30X-GT@)7MM;F\M<&5N=&EU;3HM;6-P=3UI-#@V("UM87)C:#UI
M-#@V?2 E>VUP96YT:75M.BUM8W!U/7!E;G1I=6U]("5[;6YO+7!E;G1I=6UP
M<F\Z+6UC<'4]<&5N=&EU;7T@)7MM<&5N=&EU;7!R;SHM;6-P=3UP96YT:75M
'<')O?7T*"G4]
`
end

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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