@html_text_substitution=readme.txt|readme.txt @external-css=../allegro.css @document_title=Notes on building the MinGW/Cygwin version of Allegro. @
______ ___ ___ /\ _ \ /\_ \ /\_ \ \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ /\____/ \_/__/ Notes on building the MinGW/Cygwin version of Allegro. Written by Henrik Stokseth. Robert J Ohannessian added some updates to the installation instructions and an example on how to use Dev-C++ with Allegro. Elias Pschernig and Hein Zelle revamped the cross-compilation section. Andrei Ellman updated the Cygwin section. Michal Molhanec simplified the Dev-C++ instructions. See readme.txt for a more general overview. @@heading MinGW notes This is a complete MinGW port of Allegro. This build doesn't rely on the DLL files produced by MSVC any longer but can make them itself. I'm proud to say Allegro can now make Win32 programs entirely using free professional tools. On that note I'd like to thank Peter Puck for making this a reality and for finishing off what I started. Enjoy! The screensaver example is built, but you must copy scrsave.scr to your windows/system directory (or winnt/system32 directory under Windows NT/2k/XP) if you want to test it. If you have both GNU bash and GNU fileutils installed on your system, then set the environment variable UNIX_TOOLS (set UNIX_TOOLS=1). This is needed because GNU make will automatically use sh.exe instead of command.com if it finds it somewhere in the PATH. This step is not necessary when using MSYS or Cygwin as the makefile automatically sets UNIX_TOOLS for you. "make depend" and "fixdll.bat" require that you have GNU sed installed. "fixdll.bat" requires that you have GNU sort (not DOS sort!) installed. You can download some extra utilities for MinGW from: 'http://sourceforge.net/projects/gnuwin32/' @heading Obtaining and installing the compiler & tools You have four choices when it comes to installing MinGW and Allegro on your computer:
1. Make sure you have a working MinGW installation. You can download the complete distribution or individual packages from 'http://www.mingw.org' or 'http://sourceforge.net/projects/mingw/'. You can also use the Minimal SYStem (MSYS) environment with Allegro. 2. Get the minimal DirectX 7 SDK for MinGW (dx70_mgw.zip). You download it from 'http://alleg.sourceforge.net/wip.html'. Note that this is *not* the same package as 'dx70_min.zip'. Unzip it to the compiler directory, overwriting any existing files. 3. Set the environment variable MINGDIR to the compiler directory. If you use Windows 9x, you can add the lineTest the installation by typing the following on the command line: 'gcc -v'. The answer should be similar to:set MINGDIR=c:\MinGW to your 'c:\autoexec.bat' file, assuming 'c:\MinGW' is the compiler directory, and reboot. If you use Windows ME, you can run 'msconfig', select the 'Environment' tab and then add MINGDIR. If you use Windows NT/2k/XP, you can open the Control Panel, click the 'System' applet, the 'Advanced' tab and finally the 'Environment' button, and then add MINGDIR. If you use MSYS, add instead the line export MINGDIR=/mingw to your 'c:\msys\etc\profile' file.
1. Make sure you have a working Dev-C++ installation. You can download the complete version from 'http://bloodshed.net/dev/devcpp.html'. 2. Get the DirectX SDK: go to Tools\Check for Updates/Packages... and install the DirectX package. Close Dev-C++. 3. Add 'c:\DevCpp\bin' to the beginning of your PATH environment variable and set the environment variable MINGDIR to 'c:\DevCpp'. If you use Windows 9x, you can add the linesTest the installation by typing the following on the command line: 'gcc -v'. The answer should be similar to:PATH=c:\DevCpp\bin;%PATH% set MINGDIR=c:\DevCpp to your 'c:\autoexec.bat' file and reboot. If you use Windows ME, you can run 'msconfig', select the 'Environment' tab, then modify PATH and add MINGDIR. If you use Windows NT/2k/XP, you can open the Control Panel, click the 'System' applet, the 'Advanced' tab and finally the 'Environment' button, then modify PATH and add MINGDIR.
1. Make sure you have a working Cygwin installation. You can download the setup.exe program from 'http://sources.redhat.com/cygwin/'. You will need the followin packages: bash, binutils, cygwin, cygutils, fileutils, gcc, gdb, login, make, man, mingw-runtime, sed, sh-utils, texinfo, textutils and w32api. 2. Get the minimal DirectX 7 SDK for MinGW. (dx70_mgw.zip) Download it from 'http://alleg.sourceforge.net/wip.html' and unzip it to a temporary directory, for instance 'C:\Temp'. Then move the contents of 'C:\Temp\lib' to 'C:\cygwin\lib\w32api', and the contents of 'C:\Temp\include' to 'c:\cygwin\usr\include\w32api'. If you are asked if you want to overwrite any existing files, choose to overwrite them. 3. Put the following text in '/etc/profile' (c:\cygwin\etc\profile)Test the installation by typing the following in the Bash shell: 'gcc -v'. The answer should be similar to:export ALLEGRO_USE_CYGWIN=1 export MINGDIR=/usr/local export CPATH=/usr/local/include export LIBRARY_PATH=/usr/local/lib Note: if the CPATH or LIBRARY_PATH variables are already set, you will have to append the new path to the existing one by using a colon (":") as the separator.
1. Download and install the MinGW cross-compiler. You can get the software:@heading Installing Allegro This assumes you have unzipped allegro to c:\allegro or, if you are using MSYS, you have unzipped it to c:\msys\allegro (which is equivalent to /allegro from within the MSYS environment) or, if you are using Cygwin, you have unzipped it to c:\cygwin\allegro (which is equivalent to /allegro from within the Cygwin environment). First configure Allegro for MinGW. Unless you are using MSYS or Cygwin, enter the following on the commandline (click on 'Start -> Run' then type "command" or "cmd" to get a command prompt):2. Get the minimal DirectX 7 SDK for MinGW (dx70_mgw.zip). Download it from 'http://alleg.sourceforge.net/wip.html' and unzip it in the cross-compiler base directory. Make sure you convert all text files to unix style (unzip -a) or the preprocessor will croak. The DirectX package downloaded and installed by the SDL script is not up to date: replace it with the package from the Allegro site. 3. Edit the file 'xmake.sh' in the root of your Allegro directory, replacing XC_PATH, XPREFIX and INSTALL_BASE with the right names. For example, if your compiler's base dir (the one with bin, lib and include sub-folders) is /usr/i586-mingw32msvc, and you have prefix-less binaries in /usr/i586-mingw32msvc/bin, you would use:
- directly from the MingW site: http://sourceforge.net/projects/mingw/. You need the following packages (as of February 2003):
Optionally, you can get from the SDL site, http://www.libsdl.org/extras/win32/common: opengl-devel (opengl-devel.tar.gz)
- gcc (gcc-3.2.2-20030208-1-src.tar.gz)
- binutils (binutils-2.13.90-20030111-1-src.tar.gz)
- mingw runtime (mingw-runtime-2.4.tar.gz)
- w32api (w32api-2.2.tar.gz)
- using a more convenient script with instructions for downloading: http://www.libsdl.org/extras/win32/cross/README.txt. Follow the instructions, and make sure to edit the build-crosh.sh script so it downloads the most recent version of gcc and binutils.
- as a premade Debian package called 'mingw32', which you can install with 'apt-get install mingw32'.
XC_PATH=/usr/i586-mingw32msvc/bin XPREFIX= INSTALL_BASE=/usr/i586-mingw32msvc Note that the build-cross.sh script from SDL installs binaries both with and without prefix, but some binaries (windres specifically) are installed only with prefix. If you installed the crosscompiler in /opt/cross-tools using this script, you would use: XC_PATH=/opt/cross-tools/i386-mingw32msvc/bin:/opt/cross-tools/bin XPREFIX=i386-mingw32msvc- INSTALL_BASE=/opt/cross-tools/i386-mingw32msvc 4. Run './fix.sh mingw32 --dtou' (--dtou is only needed if your Allegro directory has text files in DOS format, otherwise you can use --quick). If you are using a CVS version of Allegro, run 'make depend' to generate the build dependencies, then run 'misc/fixdll.sh' to generate the allegro.def file. You are now finished with all the preparations. 5. You can now run './xmake.sh' to build the Allegro library and then run './xmake.sh install' as root to install it. Afterwards, you can use 'xmake.sh' as you would use 'make' to compile your Allegro programs, or you can use the 'cross-make.sh' and 'cross-configure.sh' scripts from the SDL site. You must use 'xmake.sh' to compile Allegro itself though. 6. To build the documentation, use the native build process. This limitation will eventually be removed.
To activate any of these, type (for example) "make WARNMODE=1". If your copy of Allegro does not include the linker .def file (unlikely, unless you have run "make veryclean" at some point, or are using the CVS version of Allegro), you can regenerate it by running "misc\fixdll.bat". You will need to have GNU sed and sort installed for this operation to work. The version of sed that is linked from the MinGW site does not work properly; it has issues with end-of-line characters. You should get sed and sort from the link at the top of this document. Once the build is finished you can recover some disk space by running "make compress", which uses the UPX program to compress the executable files and the optimized dll. Before running "make compress", you must set the environment variable UPX_BIN to point to upx.exe. You will have to do run "make compress" before "make install" if you want the compressed dll to be copied to the windows directory. To recover even more disk space, you can run "make clean" to get rid of all the temporary files and HTML format documentation. And then the last thing, installing the library. Run:
- CROSSCOMPILE
- Set this if you are crosscompiling; it implies UNIX_TOOLS.
- WARNMODE
- Set this if you want Allegro to display and stop on nearly all warnings issued by the compiler. Allegro should compile fine with this set.
- TARGET_ARCH_COMPAT or TARGET_ARCH_EXCL
- These affect the level of processor dependant optimisation that Allegro uses. You can set either of these to the processor type you want to optimize for. The difference between these two is that TARGET_ARCH_COMPAT optimise for the given processor so that the code will still run on older processors, while TARGET_ARCH_EXCL will generate code that will run exclusively on the given processor and of course newer ones. Example: set TARGET_ARCH_COMPAT=i686
- TARGET_OPTS
- Affects the general optimisations that Allegro uses.
- UNIX_TOOLS
- If your system does not have the usual DOS tools available (`md', `rd', `copy', etc., and commands which understand the \ character), then set this to 1 to use the Unix equivalents. This is set implicitly when you set CROSSCOMPILE, and is also set automatically when you are running under bash.
END_OF_MAIN()
macro right after
your main()
function.
@heading
Compiling manually with MinGW
A simple example of a command line to compile an Allegro program with
MinGW looks like: