Original version by Trevor Dearham (WhiteKnight)

MinGW And MSYS

Packages Used For MinGW

autoconf-2.59
automake-1.9.6
binutils-2.16.91
gcc-core-3.4.4
gcc-g++-3.4.4
gcc-g77-3.4.4
gettext-0.14.1
libiconv-1.9.2
libtool-1.5.20
mingw-runtime-3.9
mingw-utils-0.3
w32api-3.5

Packages Used For MSYS

bison-2.0
flex-2.5.4a
perl-5.6.1
MSYS-1.0.11
pkg-config-0.20

Where To Get Packages From

mingw-runtime-3.9 and w32api-3.5 where obtained from MinGW. pkg-config-0.20 can be obtained from GTK+ for Windows. The rest where from the package mingw-install-20050907.tar.gz obtained from MinGW-install.

-- Link for acquiring pkg-config seems obsolete, fresher link at 2009/10/15 is http://www.gtk.org/download-windows.html

Installing Packages

  1. Uncompress mingw-install-20050907.tar.gz
  2. Move mingw-runtime-3.9.tar.gz and w32api-3.5.tar.gz into the mingw-install-20050907/mingw directory
  3. Delete ming-runtime-3.8.tar.gz, w32api-3.3.tar.gz and zlib-1.2.3-20050723-1.tar.gz, which are in the mingw-install-20050907/mingw directory
  4. Run mingw-install-20050907/setup/MSYS-1.0.11-2004.04.30-1.exe
  5. Yes to the continue with post install question.
  6. No to the do you have MinGW installed question.
  7. Run MSYS
  8. Using MSYS run mingw-install-20050907/msys/install.sh
  9. Using MSYS run mingw-install-20050907/mingw/install.sh
  10. Uncompress pkg-config-0.20.zip into "your MSYS directory"/1.0 e.g. msys/1.0
  11. Copy /share/aclocal/pkg.m4 to /mingw/share/aclocal/
  12. Then similar to Step 4 of this link:

1. Create a file /bin/pkg-config.sh, with the contents

#!/bin/sh
 if pkg-config "$@" > /dev/null 2>&1 ; then
   res=true
 else
   res=false
 fi
 pkg-config "$@" | tr -d \\r && $res

2. Make a copy of /etc/profile, in case something goes wrong, and then open /etc/profile and change line 43 from:
export HOME LOGNAME MSYSTEM HISTFILE
to:
PKG_CONFIG=/bin/pkg-config.sh
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export HOME LOGNAME MSYSTEM HISTFILE PKG_CONFIG PKG_CONFIG_PATH

3. Quit msys and then rerun it, so that the environment variables get set.

OGRE Dependencies

Packages Used

For OGRE

cegui_mk2-0.4.1

DevIL-1.6.7

freetype-2.1.10

ode-0.5

zlib-1.2.3

zziplib-0.13.44

Cg 1.4

Additional Packages For DevIL

jpeg 6b

lcms-1.14

libmng-1.0.9

libpng-1.2.8

tiff-3.7.4

Additional Package For cegui

xerces 2.7.0

Building Packages

The steps in this section assume that you have uncompressed the relevant package and that you have changed to that directory in MSYS. Also most of these packages, by default, will install to the /usr/local directory to change this use add --prefix={some directory} e.g.
--prefix=/mingw
to the configure script. Also note that MinGW, by default, will only read includes that are in the /mingw/include directory and libraries that are in the /mingw/lib directory. I will show you how to install to the /usr/local directory, as then this directory will then contain all the dependencies and as a result you will need to manually copy to the includes and libs to the /mingw directory or use the -I compiler option to specify the include file directory and the -L linker option to specify the link library directory.

The steps in this section also assume that you follow the installation of the packages in the order they are listed below.

Also, it is advisable to only keep the library files you wish to use, so if a particular package creates more that on library file, then delete the ones you don't want, e.g. zlib creates a static library (-+libz.a+-) and a dynamic link library (-+libzdll.a+- for linking at link time and zlib1.dll for runtime), so pick which one you want to keep and delete the other.

DevIL

zlib 1.2.3

  1. Open win32/Makefile.gcc and change line 34 from:

CFLAGS = $(LOC) -O3 -Wall
to:
CFLAGS = $(LOC) -mms-bitfields -O3 -Wall

  1. Run:

mkdir /usr/local
 mkdir /usr/local/include
 mkdir /usr/local/lib
 make -f win32/Makefile.gcc
 INCLUDE_PATH=/usr/local/include LIBRARY_PATH=/usr/local/lib make -f win32/Makefile.gcc install

jpeg 6b



Run:

./configure CFLAGS=-mms-bitfields
 make
 make install-lib

tiff 3.7.4


1. Open jmorecfg.h from your /usr/local/include directory.
1. Change line 161 from
typedef long INT32
to
typedef int INT32
to make it comply with the MS Windows header files.
2. Change line 226 from

#ifndef HAVE_BOOLEAN
 typedef int boolean;
 #endif
to
//#ifndef HAVE_BOOLEAN
 typedef int boolean;
 //#endif
2. Run
./autogen.sh
 ./configure CFLAGS=-mms-bitfields CXXFLAGS=-mms-bitfields
 make
 make install

Note: Read DevIL's note before building this library.

libpng 1.2.8

  1. Get libpng-1.2.8-mingwPORT.tar.bz2 from MinGW.
  2. Uncompress it to the same directory as libpng.
  3. Run:

patch -p1 < mingwPORT/mingwPORT.patch
 make -f scripts/makefile.mingw CFLAGS=-mms-bitfields
 make -f scripts/makefile.mingw prefix=/usr/local install

lcms 1.14


1. Open include/lcms.h and change line 149 from
typedef unsigned int DWORD, *LPDWORD;
to:
typedef unsigned long DWORD, *LPDWORD;
to make it comply with the MS Windows header files.
2. Open msys\1.0\mingw\include\sys\stat.h and then add the following to line 194

#define S_IXOTH 0000001
 #define S_IXGRP 0000010
 #define S_IXUSR 0000100
3. Run
./configure CFLAGS=-mms-bitfields
 make
 make install

libmng 1.0.9

1. Open /usr/local/include/icc34.h and change line 236 from
typedef u_int8_t   icUInt8Number;
 typedef u_int16_t  icUInt16Number;
 typedef u_int32_t  icUInt32Number;
 typedef u_int32_t  icUInt64Number[2];
to
typedef unsigned char  icUInt8Number;
 typedef unsigned short icUInt16Number;
 typedef unsigned int   icUInt32Number;
 typedef unsigned int   icUInt64Number[2];
2. Open makefiles/makefile.mingw
1. Change line 20 from
OPTIONS = -DMNG_NO_CMS -DMNG_ACCESS_CHUNKS -DMNG_STORE_CHUNKS
to
OPTIONS = -DMNG_FULL_CMS -DMNG_ACCESS_CHUNKS -DMNG_STORE_CHUNKS
2. Change line 33 from
#LCMSLIB=-llcms
to
LCMSLIB=-llcms
3. Change line 55 from
CFLAGS=$(ZLIBINC) $(JPEGINC) $(LCMSINC) -Wall -O3 -funroll-loops $(OPTIONS) $(ALIGN)
to
CFLAGS=$(ZLIBINC) $(JPEGINC) $(LCMSINC) -Wall -O3 -funroll-loops $(OPTIONS) $(ALIGN) -mms-bitfields
3. Run
make -f makefiles/makefile.mingw
 make -f makefiles/makefile.mingw install

Note: This make install will install to /mingw.

DevIL 1.6.7

  1. Copy /usr/local/include/lcms.h to /usr/local/include/lcms/lcms.h
  2. Change /usr/local/include/jmorecfg.h line 161 from:
    typedef long INT32;
    to:
    typedef int INT32;
    to make it comply with the MS Windows header files.
  3. Run

 ./autogen.sh
 ./configure CFLAGS=-mms-bitfields
 make
 make install

Note: I could only get TIF to be a supported format was by linking tiff's dll files, as tiff's static library files have unresovled externals for zlib and jpeg.

cegui

xerces 2.7.0

  1. Download the mingw-msys patch from here.
  2. Put the patch in your xerces directory e.g. ~/xerces-c-src_2_7_0.
  3. Go to that directory and run:
    patch -p1 < xerces-c-src_2_6_0.patch
  4. Run export XERCESCROOT={fill in your path to the base of xerces} e.g.
    export XERCESCROOT=/home/Trevor/xerces-c-src_2_7_0
    Note: Don't use ~, as it will not resolve to being your home directory.
  5. Then go to src/xercesc and run:

 ./runConfigure -p mingw-msys -c gcc -x g++ -z -mms-bitfields
 make
 make install

freetype 2.1.10



Run:

 ./autogen.sh
 ./configure CFLAGS=-mms-bitfields
 make
 make install

cegui 0.4.1



I could only get this to build with the help of Code::Blocks, which uses MinGW. I couldn't get MinGW to import and export correctly with MSYS, but it did compile it and therefore it should be possible to build cegui with MSYS.

  1. Download the patch for cegui here and put it in your cegui source directory.
  2. Using MSYS run the following from your cegui source directory:
    patch -p1 < cegui.patch
  3. Download the latest Code::Blocks project files (CB_mingw_files.zip) from here.
  4. Extract the Code::Blocks project files to the cegui directory.
  5. Create a dependencies directory inside your cegui source directory and inside that directory create an include and a lib directory.
  6. Copy the contents freetype's include directory and xerces's src into dependencies/include and freetype's objs\.libs\libfreetype.a and xerces's xerces-c-src_2_7_0\lib\libxerces-c.dll into dependencies/lib.
  7. Open makefiles\win32\CB_Mingw\CEGUI.workspace with Code::Blocks.
  8. Go to Build options of CEGUIBase.
    1. Open the Linker tab and change freetype.dll to freetype and add xerces-c for both build targets.
    2. Open the Compiler tab and then the #defines tab inside and add the follow define, so that xerces will be used instead of tinyxml:
      CEGUI_WITH_XERCES
  9. Right click on DirectX9GUIRenderer and select Activate Project and then hold down the crtl and shift keys and then press the down arrow until DirectX9GUIRenderer is below FalagardBase. Use the sample technique to move OpenGLGUIRenderer below FalagardBase. This should allow you to only build CEGUIBase, TaharezLook, WindowsLook and FalagardBase, as this is all you should need.
  10. Build the workspace.




Note:

  1. If you get a link error when building CEGUIBase which contains the following text: undefined reference to inflate, inflateEnd, inflateReset and inflateInit2_, then add open the Build options for CEGUIBase and then the Linker tab and add zdll and then copy libzdll.a to dependencies/lib.
  2. You don't need to build CEGUISampleHelper, the samples and the DirectX and OpenGL renderers, and therefore it goes out of the scope of this wiki and therefore above I haven't mention the changes necessary to build them.



OGRE Dependencies Not Already Built

zziplib 0.13.44

I could only get this to build with the help of Code::Blocks, which uses MinGW.

1. Import msvc7/zziplib.sln into Code
:Blocks.
2. Go to the Build options and select the Directories tab and then the Compiler tab inside it and then do the following for all build targets.
1. Add the directory where you have put the include files for zlib.
2. Add
..\zzip
to the directories list.
3. Open the Directories tab's Linker tab and then add zlib's library file for all buld targets.
4. Open the Compiler tab's Other options tab and add the following for all build targets
-mms-bitfields
5. Open zzip\_config.h and change line 9 from



 #ifndef ZZIP_HAVE_BYTESWAP_H 
 #define ZZIP_HAVE_BYTESWAP_H  1 
 #endif
to



 //#ifndef ZZIP_HAVE_BYTESWAP_H 
 //#define ZZIP_HAVE_BYTESWAP_H  1 
 //#endif
6. Build the workspace.



ode 0.5

  1. Open config/user-settings.
    1. Change line 14 from:
      PLATFORM=unix-gcc
      to:
      PLATFORM=mingw
      .
    2. Change line 44 from:
      #OPCODE_DIRECTORY=OPCODE
      to:
      OPCODE_DIRECTORY=OPCODE
  2. Run:

 make configure
 make ode-lib

Cg 1.4


  1. Using MinGW, go to Cg's lib directory.
  2. Run:
    reimp -c cg.lib


This should create two files, namely cg.def and libcg.a.


<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.