home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / src / mingw-runtime-19991107 / mingw / readme.txt < prev    next >
Encoding:
Text File  |  1997-11-04  |  28.8 KB  |  686 lines

  1.                       Minimalist GNU-Win32 Readme
  2.                             version 0.1.3
  3.                            March 20, 1997
  4.              Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  5.  
  6.  
  7. 0. Introduction
  8.  
  9. Mingw32 is short for the Minimalist GNU-Win32 package, and it is a 
  10. package which allows you to use GCC (as supplied by Cygnus in their GNU-
  11. Win32 or Cygwin32 package) the GNU compiler, on Win32 platforms like 
  12. Windows 95 or NT, to compile "native" programs.
  13.  
  14. In this case "native" means programs which don't require extra DLLs like 
  15. the cygwin DLL. Mingw32 programs use CRTDLL.DLL to provide their C run 
  16. time library functions, and CRTDLL.DLL is supplied with all current 
  17. Win32 platforms. Thus the programs are light weight and easy to 
  18. distribute, they also do not automatically fall under the GNU Public 
  19. License as programs written with the GPL version of Cygwin32 do.
  20.  
  21.  
  22. 0.1 Archive Contents
  23.  
  24. Mingw32 version 0.1.3 is distributed in two files, mingw32_013.tar.gz 
  25. and mingsrc013.tar.gz. The first file contains the following components:
  26.  
  27.     - Import libraries for building programs which use the
  28.       CRTDLL.DLL C run time library supplied with Win32 platforms.
  29.  
  30.     - crt0.o and dllcrt0.o, two "startup code" object files that
  31.       perform program or DLL initialization without using
  32.       CRTDLL.DLL (instead of CYGWIN.DLL).
  33.  
  34.     - specs, a configuration file for GCC which defines appropriate
  35.       options for creating executables which use the CRTDLL.DLL C
  36.       run time library.
  37.  
  38.     - Include files with appropriate type and macro definitions,
  39.       and function prototypes for use with CRTDLL.DLL.
  40.  
  41. The source distribution (mingsrc013.tar.gz) contains the .def files and 
  42. source files used to create the various import libraries and object 
  43. files in the above list.
  44.  
  45.  
  46. 0.2 Usage Notes
  47.  
  48. Unlike some previous releases of Mingw32 the current version defaults to 
  49. building console applications, the same way that GCC normally does when 
  50. installed from the Cygnus distribution. The Mingw32 specs file also 
  51. introduces two command line arguments to GCC which can be used to 
  52. conveniently specify a console or GUI type build. When building console 
  53. programs "-console" can be used on the GCC command line, while GUI 
  54. programs can be built by specifying "-windows" (I tried defining -gui, 
  55. and it works, but produces an annoying warning about -gui not being 
  56. supported (?)). For example:
  57.  
  58.     gcc -o hellogui.exe hellogui.c -luser32 -windows
  59.  
  60. Although using different "crt0" files for GUI and console applications 
  61. has been suggested I have left the system more-or-less as it was in 
  62. 0.1.1: crt0 sets up for and calls main, and if you don't supply a main 
  63. there is one in libmingw32.a, which in turn calls WinMain (actually 
  64. WinMain@16). This allows either main or WinMain entry points in console 
  65. or GUI applications, but if you don't supply main or WinMain, or don't 
  66. prototype WinMain as __stdcall__ you will get a linker error about an 
  67. "unresolved reference to WinMain@16." This is unfortunately cryptic, but 
  68. otherwise the system works quite well.
  69.  
  70. An important note if you want to rebuild from the sources of Mingw32 or 
  71. otherwise use the special version of Jam made for Mingw32: you need to 
  72. have a version of "rm", the UNIX equivalent of del, somewhere in your 
  73. path to use the current Jambase (which is built into the Jam 
  74. executable). The version that comes with the Cygnus files is perfectly 
  75. adequate.
  76.  
  77.  
  78. 0.3 Fixes and Improvements
  79.  
  80. Numerous small bug fixes have been made in the header files.
  81.  
  82. Floating point initialization, originally added in version 0.1.2, has 
  83. been modified to use the _fpreset function from CRTDLL.DLL instead of 
  84. cryptic and possibly less portable assembly code.
  85.  
  86. A new DLL-building option has been added to the specs file so that the 
  87. following link line will appropriately link in dllcrt0.o instead of the 
  88. normal crt0.o, and set the entry point correctly:
  89.  
  90.     gcc -dll -o dll.dll dll.o -Wl,dll.exp
  91.  
  92. A bug that would cause the wrong include files to be included in dual 
  93. installations of Cygwin32 and Mingw32 has been fixed (I hope) in the 
  94. Mingw32 specs file.
  95.  
  96. Alongside this release is a new release of Jam specially built for use 
  97. with Mingw32. It should be available from the same place you got this 
  98. file. This release of Jam includes rules for building DLLs, including 
  99. resources in your executables and creating import libraries. I also 
  100. intend to distribute a small set of example files showing how to do all 
  101. of these things with Mingw32 and Jam.
  102.  
  103. In the "coming soon" category I have a version of the GNU Standard C++ 
  104. library ported to Mingw32. This means you can use iostreams, complex 
  105. numbers and all those neat STL (Standard Template Library) things 
  106. without needing the Cygwin DLL. I hope to put this port up for 
  107. downloading soon (along with the source of course).
  108.  
  109.  
  110.  
  111. 1. Installing
  112.  
  113. 1.1 Download and Unpack GNU-Win32 Beta 17.1
  114.  
  115. Because of the enormous size of the beta 17.1 release from Cygnus this 
  116. process will require about 85 MB or more of free disk space. The first 
  117. step, after downloading the Mingw32 package, is to download the GCC 
  118. binary distribution, all.tar.gz, from Cygnus (or a mirror), which is 
  119. about 10 MB. (Of course, if you just want the Cygwin32 install and are 
  120. not actually interested in adding on Mingw32 you don't need the Mingw32 
  121. package at all.)
  122.  
  123. Just to be safe, and if you have the 10 MB to spare, you should probably 
  124. copy the all.tar.gz file to a reasonably safe place at this point. This 
  125. will save you from the pain of downloading it again if something goes 
  126. wrong later.
  127.  
  128. To complete this step you need a gzip program (or just gunzip) and a tar 
  129. program. You can use the ones supplied by Cygnus (although some people 
  130. seem to have trouble with them, especially if you try to use pipes) or 
  131. one of the other ports available from your favorite freeware/shareware 
  132. software site.
  133.  
  134. First un-gzip the file with a command line like:
  135.     gunzip all.tar.gz
  136. or
  137.     gzip -d all.tar.gz
  138.  
  139. This will produce a all.tar file and erase the all.tar.gz file (there 
  140. are options for gzip if you want to keep the original around). The tar 
  141. file is about 40 MB.
  142.  
  143. Make a directory for the cygnus stuff, such as C:\cygnus for example. 
  144. Move the tar file there (e.g. move \tmp\all.tar \cygnus). DonÆt copy it 
  145. unless you like waiting and wasting 40 MB of disk space.
  146.  
  147. Unpack the tar file into your new directory with a command line like:
  148.     tar xvf all.tar
  149.  
  150. Run from the new directory (now containing the tar file). This is the 
  151. step where disk space usage reaches its peak, since the tar extraction 
  152. does not delete the all.tar file, and the amount of space taken by the 
  153. extracted files plus the tar file itself is well in excess of 80 MB 
  154. (mainly because, on my system at least, the files which are symbolic 
  155. links in the tar archive are copied as they are expanded onto the FAT 
  156. filesystem, so for example, a symbolic link to cygwin.dll, a 3 MB file, 
  157. takes an extra 3 MB, since the file is simply duplicated in the new 
  158. location). I could not actually do this on my laptop and had to extract 
  159. the tar file from a mounted network drive!
  160.  
  161. NOTE: From here on I will refer to files as if you had installed in 
  162. C:\cygnus. If you installed somewhere else then just replace C:\cygnus 
  163. with the appropriate path wherever it occurs.
  164.  
  165.  
  166. 1.2 Setup Cygwin32
  167.  
  168. This step is not 100% necessary, but it helps at this point to determine 
  169. if youÆve gotten this far without any major problems. Also, if you 
  170. intend to use both Cygwin32 and Mingw32 you will have to do some of 
  171. these steps eventually.
  172.  
  173. GCC and the other programs in the compiler suite all require cygwin.dll 
  174. to run. There are two copies of this file: one in C:\cygnus\H-i386-
  175. cygwin32\bin (this might be a symbolic link), and one in C:\cygnus\H-
  176. i386-cygwin32\i386-cygwin32\lib (the original). Since this DLL is 
  177. required by all Cygwin32 programs it makes sense to put one copy of it 
  178. in your C:\Windows\System directory (or equivalent) and remove the extra 
  179. copies. This will also save you headaches when the next release comes 
  180. along and you have to make sure that everything is using the latest 
  181. release of the DLL.
  182.  
  183. After doing that run the cygwin32.bat batch file included with this 
  184. distribution, or otherwise perform the following settings:
  185.  
  186.     PATH=%PATH%;C:\cygnus\H-i386-cygwin32\bin
  187.     SET GCC_EXEC_PREFIX=C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-
  188.         cygwin32\cygnus-2.7.2-961023
  189.     SET LIBRARY_PATH=/cygnus/H-i386-cygwin32/lib/gcc-lib/i386-
  190.         cygwin32/cygnus-2.7.2-961023:/cygnus/H-i386-cygwin32/i386-
  191.         cygwin32/lib:/cygnus/H-i386-cygwin32/lib
  192.     SET C_INCLUDE_PATH=/cygnus/H-i386-cygwin32/lib/gcc-lib/i386-
  193.         cygwin32/cygnus-2.7.2-961023/include:/cygnus/H-i386-
  194.         cygwin32/i386-cygwin32/include:/cygnus/include
  195.     SET CPLUS_INCLUDE_PATH=%C_INCLUDE_PATH%
  196.  
  197. NOTE: You may need to increase the amount of environment space available 
  198. at the command prompt to get these extremely long environment variables 
  199. set. You can do this under Windows 95 by modifying the properties of the 
  200. command prompt shortcut you use under the "Program" tab, adding a 
  201. /e:#### argument to the command line COMMAND.COM, where #### is the 
  202. number of bytes to set aside for the environment.
  203.  
  204. NOTE: Under Windows 95 changes made in your autoexec.bat file will not 
  205. show up in new DOS boxes unless you reboot your machine.
  206.  
  207. Now write and compile a small test hello world program like this:
  208.  
  209. #include <stdio.h>
  210.  
  211. int
  212. main ()
  213. {
  214.     printf ("Hello, world!\n");
  215.     return 0;
  216. }
  217.  
  218. Then compile it like this (assuming your file is called hello.c):
  219.  
  220.     gcc -o hello.exe hello.c
  221.  
  222. The compile should proceed without problems and you should be able to 
  223. run the hello program at the end. It should print "Hello, world!" 
  224. (without the quotes) to the console and then return to the command 
  225. prompt.
  226.  
  227. If you wanted a full Cygwin32 install you now have it. With this setup 
  228. (say, by adding those lines above to your autoexec.bat or global 
  229. settings) you can port a great deal of UNIX code to run under Win32 
  230. systems. No more steps are necessary.
  231.  
  232. If you are a minimalist or otherwise want to save disk space you should 
  233. continue from here. Also if you intend to use the Minimalist GNU-Win32 
  234. files to compile programs which don't use the Cygwin32 API you will need 
  235. to do some of the things mentioned below.
  236.  
  237. If the compile didn't work for some reason check very carefully that you 
  238. followed the instructions above correctly and then check whether one or 
  239. more of the files in the download got corrupted. If neither of these 
  240. seems to be the case then your system is not behaving like my system. 
  241. Try looking at the troubleshooting section later in this file, and if 
  242. none of that helps then you can email me (colin@bird.fu.is.saga-
  243. u.ac.jp), though I can't promise I'll be a lot of help.
  244.  
  245.  
  246. 1.3 Separating the Win32 API Files
  247.  
  248. Mingw32 and Cygwin32 share the same set of Win32 API include files and 
  249. import libraries as included in the GCC distribution from Cygnus. In 
  250. order to use the Win32 API with a dual setup or with Mingw32 alone you 
  251. will have to separate those files from the bulk of the Cygwin32 API 
  252. files.
  253.  
  254. Make a new directory to serve as the root for the Win32 API files. I put 
  255. mine under C:\cygnus and called it win32, but you can put it where you 
  256. like and just replace later references to C:\cygnus\win32 with your own 
  257. root directory.
  258.  
  259. Move the following from C:\cygnus\H-i386-cygwin32\i386-cygwin32\include 
  260. to a new C:\cygnus\win32\include directory:
  261.  
  262. windows.h, winadvapi.h, winbase.h, wincon.h, windef.h, windowsx.h, 
  263. winerror.h, wingdi.h, winkernel.h, winnt.h, wintypes.h, winuser.h, 
  264. winversion.h, commdlg.h, ddeml.h and the Windows32 sub-directory and all 
  265. its contents.
  266.  
  267. Move the following files from C:\cygnus\H-i386-cygwin32\i386-
  268. cygwin32\lib to a new C:\cygnus\win32\lib directory:
  269.  
  270. libadvapi32.a, libcomctl32.a, libcomdlg32.a, libctl3d32.a, libgdi32.a, 
  271. libglaux.a, libglu32.a, libimm32.a, libkernel32.a, liblz32.a, 
  272. libmapi32.a, libmfcuia32.a, libmgmtapi.a, libmpr.a, libmsacm32.a, 
  273. libnddeapi.a, libnetapi32.a, libodbc32.a, libodbccp32.a, libole32.a, 
  274. liboleaut32.a, liboledlg.a, libolepro32.a, libopengl32.a, libpenwin32.a, 
  275. libpkpd32.a, librasapi32.a, librpcdce4.a, librpcndr.a, librpcns4.a, 
  276. librpcrt4.a, libscrnsave.a, libshell32.a, libsnmp.a, libsvrapi.a, 
  277. libtapi32.a, libth32.a, libthunk32.a, liburl.a libuser32.a, libvdmdbg.a, 
  278. libversion.a, libvfw32.a, libwin32spl.a, libwinmm.a, libwinserve.a, 
  279. libwinspool.a, libwinstrm.a, libwow32.a, libwsock32.a, libwst.a.
  280.  
  281. That list is quite excessive for most basic Windows programming, which 
  282. will only require kernel32, user32, gdi32, shell32 and possibly a couple 
  283. of others like the common control and dialog libraries or advapi32. You 
  284. may not need the ODBC support, or OLE, or Pen Windows, TAPI and on and 
  285. on. Still, if you have the space and intend to use the Win32 API you 
  286. might as well keep the ones youÆre not sure youÆll ever use around.
  287.  
  288. The lists above can also act as lists of files you can safely delete if 
  289. you are never going to use the Win32 API in your programs except that 
  290. libkernel32.a is still required even if you donÆt use the Win32 API 
  291. yourself. Note that this means that libkernel32.a must be on the library 
  292. path as well, even if you donÆt use the Win32 API. (Actually this 
  293. appears to be an artifact of the specs file supplied with Cygwin32. If 
  294. you like, and feel up to it, you can play around with the specs file and 
  295. remove the reference to kernel32.)
  296.  
  297. Here are the variable settings you need to make to allow GCC to find the 
  298. Win32 API files in their new positions:
  299.  
  300.     SET LIBRARY_PATH=%LIBRARY_PATH%:/cygnus/win32/lib
  301.     SET C_INCLUDE_PATH=%C_INCLUDE_PATH%:/cygnus/win32/include
  302.     SET CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%:/cygnus/win32/include
  303.  
  304. The file win32-api.bat performs these settings. Run it after you run 
  305. cygwin32.bat (or mingw32.bat below).
  306.  
  307. At this point you should be able to compile programs that use the Win32 
  308. API, just as you could before. You might want to do a simple test 
  309. compile to find out, for example this code:
  310.  
  311. #include <windows.h>
  312.  
  313. int STDCALL
  314. WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
  315. {
  316.     MessageBox (NULL, "Test message", "Test", MB_OK);
  317.     return 0;
  318. }
  319.  
  320. Should compile with the following command line:
  321.     gcc -o test.exe test.c -lkernel32 -luser32 -Wl,--subsystem,windows
  322.  
  323. It will produce a warning at link time about not finding 
  324. _WinMainCRTStartup, but this is harmless.
  325.  
  326. If you have trouble check the troubleshooting section later in this 
  327. file.
  328.  
  329.  
  330. 1.4 Specs
  331.  
  332. The file C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-
  333. 2.7.2-961023\specs includes a set of options and defaults for GCC, 
  334. including such things as which libraries are automatically linked into 
  335. executables and such. A different specs file is required depending on 
  336. whether you use Cygwin32 or Mingw32.
  337.  
  338. To avoid GCC accidentally using the wrong specs file move specs to 
  339. C:\cygnus\H-i386-cygwin32\i386-cygwin32\lib.
  340.  
  341. You can verify what specs file is being used by attempting a compile 
  342. with the -v option to gcc. Note that if no specs file is mentioned the 
  343. compiler will default to Cygwin32 behavior.
  344.  
  345.  
  346. 1.5 The Mingw32 Files
  347.  
  348. Now we can install the Mingw32 files and start making programs which 
  349. donÆt use cygwin.dll or the Cygwin32 API. I install my copy under a 
  350. separate directory called C:\mingw32, but you could put them wherever 
  351. you like (e.g. C:\cygnus\mingw32). Again simply replace references to 
  352. C:\mingw32 with the directory where you perform your installation.
  353.  
  354. After making the install directory copy mingw32_012.tgz to that 
  355. directory and run a command like this:
  356.     gunzip -d mingw32_012.tgz
  357.  
  358. in that directory, followed by:
  359.     tar xvf mingw32_012.tar
  360.  
  361. This will unpack the required files. Then you can use the following 
  362. environment variable settings (as included in mingw32.bat) to setup for 
  363. compiles using Mingw32:
  364.  
  365.     PATH=%PATH%;C:\cygnus\H-i386-cygwin32\bin
  366.     SET GCC_EXEC_PREFIX=C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-
  367.         cygwin32\cygnus-2.7.2-961023\
  368.     SET LIBRARY_PATH=/mingw32/lib
  369.     SET C_INCLUDE_PATH=/mingw32/include:/mingw32/include/nonansi
  370.     SET CPLUS_INCLUDE_PATH=%C_INCLUDE_PATH%
  371.  
  372. The mingw32.bat file can be used the same way as the cygwin32.bat file. 
  373. Depending on which one you run you will be able to do Mingw32 compiles 
  374. or Cygwin32 compiles. Note that whichever one you use you must follow it 
  375. with an invocation of win32-api.bat so that libkernel32.a will be in the 
  376. library path.
  377.  
  378. Setup is now complete, you have complete working Mingw32 and Cygwin32 
  379. compiles available along with the bash shell, tons of UNIX-like 
  380. utilities.
  381.  
  382. If you had trouble with any of the steps above then the next section is 
  383. for you.
  384.  
  385.  
  386.  
  387. 2. Troubleshooting Setup Problems
  388.  
  389. If you ran into trouble at any stage in the section 1 here are a few 
  390. general guidelines as well as some solutions to common problems.
  391.  
  392. 2.1 Winzip, gunzip or tar Complains of Errors
  393.  
  394. Winzip may complain that it could not create a file with garbage 
  395. characters in it's name. Gunzip, gzip or tar may complain about 
  396. formatting errors. Usually this means that the downloaded file is 
  397. corrupted. As of this writing this problem was most commonly caused when 
  398. downloading the files from Geocities using Netscape Navigator for 
  399. Windows 95 or NT. A combination of a badly set MIME type at Geocities 
  400. and a bug in Netscape will corrupt files saved with "Save Link As" (and 
  401. clicking on the links would display the files as garbage text). At this 
  402. time the only solutions are to use another browser (IE, or Netscape for 
  403. UNIX or Apple systems) or to download from the Japanese mirror 
  404. (http://www.fu.is.saga-u.ac.jp/~colin/gcc.html). Hopefully Geocities 
  405. will eventually fix their problem.
  406.  
  407.  
  408. 2.2 Compile and Link Time Problems: General Steps
  409.  
  410. First, evaluate that your environment variables are what you expect them 
  411. to be by running the SET command with no arguments (if you are using the 
  412. bash shell then the output of env might also be illuminating). Do this 
  413. immediately before you attempt a compile in the same window as the 
  414. compile.
  415.  
  416. Secondly include the '-v' option on the gcc command line. This will give 
  417. you far more information on what happens during the compile, especially 
  418. important are which specs file is being used and what include file 
  419. directories are being read, as well as the arguments to cpp and ld.
  420.  
  421. If you send me email about a problem the output of these two general 
  422. steps will be very helpful in making a diagnosis.
  423.  
  424.  
  425. 2.3 Cannot exec 'cpp'
  426.  
  427. On compiling you get an error message like this:
  428.  
  429.     GCC.EXE: installation problem, cannot exec `cpp': No such file
  430.     or directory
  431.     GCC.EXE: Internal compiler error: program cpp got fatal signal 127
  432.  
  433. This means more or less what it says. The program cpp is the C 
  434. preprocessor (it strips comments and interprets all those lines 
  435. beginning in '#') and running it is the first step in compiling a C or 
  436. C++ program. The problem here is that GCC.EXE cannot find CPP.EXE. 
  437. Normally CPP.EXE is in the directory C:\cygnus\H-i386-cygwin32\lib\gcc-
  438. lib\i386-cygwin32\cygnus-2.7.2-961023\. If the file is there then 
  439. probably the GCC_EXEC_PREFIX environment variable is not correctly set.
  440.  
  441.  
  442. 2.4 Can't Find Include Files
  443.  
  444. You get an error like this:
  445.  
  446.     hello.c:2: No include path in which to find stdio.h
  447.  
  448. This, again, means what it says (more or less). The compiler cannot find 
  449. the file stdio.h which is #included in the source file hello.c at line 
  450. 2. Of course the particular file names may differ in your case. If this 
  451. is not simply a case of including a really non-existent file or 
  452. misspelling the file name then probably your C_INCLUDE_PATH or 
  453. CPLUS_INCLUDE_PATH environment variable is wrong. (If not, see "But the 
  454. environment variables are right" below.)
  455.  
  456.  
  457. 2.5 Can't Find Libraries
  458.  
  459. At link time you get an error like this:
  460.  
  461.     ld: cannot open -lkernel32: No such file or directory
  462.  
  463. This one is a bit cryptic, mainly because the name of the file that 
  464. can't be opened is not "-lkernel32" but "libkernel32.a". "-lname" is the 
  465. ld command line syntax for linking the library named "libname.a". So 
  466. basically this error is saying it can't find libkernel32.a (or whatever 
  467. library matches the error you got). If you weren't trying to manually 
  468. link in a library that doesn't exist or was misspelled (by accidentally 
  469. including the 'lib' or '.a' on the command line for example) then 
  470. probably your LIBRARY_PATH environment variable is wrong. (If not, see 
  471. "But the environment variables are right" below.)
  472.  
  473.  
  474. 2.6 But the Environment Variables are Right!
  475.  
  476. You had one of the problems with not finding include files or libraries 
  477. but the environment variables all seem to be pointing at the right 
  478. places and the files are all there.
  479.  
  480. If you installed on a drive other than C: drive this may be your 
  481. problem. The Cygwin DLL, and thus all the basic compiler tools, 
  482. automatically map C: drive to (UNIX-style) '/'. Thus /cygnus is actually 
  483. C:\cygnus. There are a few ways to fix this (without reinstalling on C: 
  484. drive):
  485.  
  486.     - Map your actual install directory to /cygnus using mount
  487.       (mount.exe is included with the Cygnus distribution). Simply
  488.       type "mount D:\mydir /cygnus" (assuming you installed in the
  489.       directory \mydir on D: drive). Similar tricks can be used for
  490.       other directories which you may have installed on other drives.
  491.  
  492.     - Change the mount of C: to / to the actual install drive. This is
  493.       possible by using the registry editor (regedit) included with
  494.       Windows. Start the editor and go to the key (or folder) "My
  495.       Computer\HKEY_CURRENT_USER\Software\Cygnus Support\CYGWIN.DLL
  496.       setup\b15.0\mounts". Under this key there are several numbered
  497.       keys. One of them will have the variables "native" set to "c:" and
  498.       "unix" set to "/". Change the value of "native" to whatever drive
  499.       you did your install on and everything should be fixed. NOTE: You
  500.       should probably do this after a fresh boot with no Cygnus based
  501.       programs running.
  502.  
  503.  
  504. 2.7 Unresolved References to _impure_ptr and/or _ctype_ etc.
  505.  
  506. At link time your code produces unresolved references to _impure_ptr, 
  507. _ctype_ and/or _errno, among others.
  508.  
  509. This is the result of using the Cygwin header files but linking against 
  510. the Mingw32 libraries. I have hopefully managed to fix the bug that used 
  511. to cause this problem on any dual installation, but perhaps I haven't. 
  512. To check you can run gcc with the -v option and see if the list of 
  513. directories searched for include files contains any include directories 
  514. with Cygwin headers in them. If everything is working correctly you 
  515. should only see the directories on your C_INCLUDE_PATH in this list.
  516.  
  517. If you have this problem then you may have to modify the Mingw32 specs 
  518. file, specifically the part that says:
  519.  
  520. *cpp:
  521. %{posix:-D_POSIX_SOURCE} -iprefix /mingw32/include/
  522.  
  523. These are options that get passed to the C preprocessor by gcc. Consult 
  524. the documentation for cpp and try options other than -iprefix. You may 
  525. have to use -nostdinc and/or -nostdinc++ plus -I options to get the 
  526. correct behavior.
  527.  
  528.  
  529. 2.8 My Program Doesn't Print Any Output OR My Windows Program Creates
  530.     A Console Window
  531.  
  532. Your console application runs, but doesn't print any output, or your GUI 
  533. application runs fine, but always creates an extra console window when 
  534. run from Explorer or by double clicking on an icon.
  535.  
  536. These are basically two sides of the same coin. You have created a GUI 
  537. (or console) application when you meant to create a console (or GUI) 
  538. application. By default gcc creates console applications. If you make a 
  539. windows GUI application with a WinMain and all that you will still get a 
  540. console application if you don't tell gcc what to do at link time. The 
  541. relevant options are "-windows" "-Wl,--subsystem,windows" or "-Wl,--
  542. subsystem,console". The first two, if used on a gcc link line, will 
  543. create a proper GUI application. The last will make sure you are making 
  544. a console application.
  545.  
  546.  
  547.  
  548. 3. Optimizing and Reducing Disk Space Usage
  549.  
  550. There are still vast amounts of disk space used by the Cygwin32 
  551. installation on your hard-drive, and much of it can be removed while 
  552. still maintaining a fully functional compiler system. The following 
  553. sections point out which files you actually need for certain tasks, so 
  554. that you wonÆt delete them.
  555.  
  556.  
  557. 3.1 Bare Minimum
  558.  
  559. For C only, Mingw32 compiles which donÆt use the Win32 API, and if you 
  560. donÆt want to produce DLLs or do debugging with any of the GNU tools the 
  561. list of files required is as follows:
  562.  
  563. In C:\cygnus\H-i386-cygwin32\bin:
  564.     ar.exe, as.exe, gcc.exe, ld.exe
  565.  
  566. In C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-
  567. 961023:
  568.     cc1.exe, cpp.exe, libgcc.a
  569.  
  570. In C:\cygnus\win32\lib:
  571.     libkernel32.a
  572.  
  573. Plus all the files in C:\mingw32\lib and C:\mingw32\include and their 
  574. subdirectories.
  575.  
  576.  
  577. 3.2 C++ Support
  578.  
  579. To add C++ Support to the above the following extra files are required:
  580.  
  581. In C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-
  582. 961023:
  583.     cc1plus.exe
  584.  
  585. Note that this does not include support for the standard C++ libraries 
  586. (only the C run time libraries) or for iostreams. That support is still 
  587. only available with the Cygwin32 API.
  588.  
  589.  
  590. 3.3 Extra Utilities of Extreme Usefulness
  591.  
  592. Even if you do not use the bash shell or UNIX utilities in general some 
  593. of the utilities in C:\cygnus\H-i386-cygwin32\bin are extremely useful 
  594. for debugging and probably shouldnÆt be deleted if you intend to do any 
  595. actual programming using the system.
  596.  
  597. These include:
  598.     dlltool.exe, gdb.exe, nm.exe, and strip.exe.
  599.  
  600.  
  601. 3.4 Jam
  602.  
  603. Jam is a make replacement program that I use pretty much exclusively, 
  604. which is why you don't find any Makefile, makefile, makefile.mk or all 
  605. that in the stuff that I do. You do find jamfiles and the occaisional 
  606. mk.bat file. The executable of Jam is only 80 KB and the program is 
  607. incredibly useful, so I would encourage you do download the special 
  608. Mingw32 version and check it out. The Mingw32 version has built in rules 
  609. for adding resources, building DLLs and import libraries as well as 
  610. normal C and C++ files. The source code is, of course, freely available.
  611.  
  612. The actual point of this section though, is to point out that to use Jam 
  613. you need not only the Jam executable but also rm.exe from the Cygwin 
  614. distribution. You also might want to download rcl.exe and res2coff.exe 
  615. as these are the helper programs Jam expects to use for resource script 
  616. handling.
  617.  
  618.  
  619. 4. Legalities
  620.  
  621. All of the code in the Mingw32 package is available as public domain 
  622. source. You may use and modify the code as you like. Of course I 
  623. encourage you to write software which is free, either public domain or 
  624. under the GNU Public License for example, but that is up to you. Linking 
  625. with the libraries included with Mingw32 similarly does not impose any 
  626. licensing restrictions on your code or binaries.
  627.  
  628. The library libgcc.a, which is linked into all code produced with GCC, 
  629. is under a special version of the LGPL (as far as I know, you should 
  630. check for yourself) which allows the distribution of programs which are 
  631. simply linked with unmodified versions of libgcc.a with no licensing 
  632. restrictions.
  633.  
  634. Thus, using Mingw32, you should be able to produce code with no 
  635. licensing restrictions imposed by use of the compiler or libraries. The 
  636. Cygwin32 API, and the GNU libraries are another matter and you should 
  637. consult their license agreements.
  638.  
  639. Again I must stress that I am not a lawyer and the above statements only 
  640. reflect my personal understanding of the situation. You would be well 
  641. advised to consult the actual text of the appropriate copyright notices 
  642. and license agreements if you have any concerns.
  643.  
  644.  
  645. 5. Support
  646.  
  647. First of all, the Mingw32 code is supplied AS IS with NO WARRANTY either 
  648. EXPRESS or IMPLIED.
  649.  
  650. There is also no support staff standing by to take your calls. There 
  651. are, however, a few people, including myself, using Mingw32 who might be 
  652. able to help you. If you have problems you can email me at 
  653. colin@bird.fu.is.saga-u.ac.jp and I will try to get back to you. No 
  654. guarantees, but I will do my best.
  655.  
  656.  
  657. 6. Suggestions and Contributions
  658.  
  659. If you find a bug in the Mingw32 files themselves then feel free to 
  660. report it, or even better to supply a fix, by emailing me at 
  661. colin@bird.fu.is.saga-u.ac.jp. Any fixes I receive will probably go into 
  662. the next release, and if they seem high-priority I may put the patched 
  663. files on my web page until I can make a complete release. Please note 
  664. that if you supply code it must be in the public domain or I cannot 
  665. include it in Mingw32. Please attach an appropriate legal message to the 
  666. code or otherwise make sure that there are no copyright issues. Of 
  667. course if you just suggest a possible method for solving a problem or 
  668. point out a bug then there should be no need for all that.
  669.  
  670. Note that the Win32 API header files are not actually part of the 
  671. Mingw32 package. I know there are many bugs and omissions, and I try to 
  672. keep informed about them, so I do appreciate mail pointing them out. 
  673. However I canÆt fix these problems at the source. You should send email 
  674. to Scott Christley (the author of the GPL windows32-api) or possibly to 
  675. Cygnus. Sending email to me might get me to mention it on my homepage or 
  676. fix it in my personal copy of the header files, but thatÆs about it 
  677. (sorry).
  678.  
  679. Aside from bug reports, suggestions for improvements, testing of the 
  680. header files and otherwise praise or criticism is all welcome in my 
  681. inbox.
  682.  
  683. Good luck,
  684. Colin Peters (colin@bird.fu.is.saga-u.ac.jp)
  685.  
  686.