Ticket #9275: scummvm-compiling-mingw.txt

File scummvm-compiling-mingw.txt, 11.8 KB (added by SF/merkur-kun, 10 years ago)

Wiki-source for Compiling ScummVM/MinGW

Line 
1== Compiling ScummVM with Minimalist GNU for Windows (MinGW) ==
2
3MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications. It provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs.
4
5== Things needed ==
6
7=== MinGW and MSYS ===
8
9[http://http://www.mingw.org/ MinGW Homepage]
10-
11[http://sourceforge.net/projects/mingw/files/ MinGW Downloads]
12
13Downloading MinGW and it's tools is a lot easier today, thanks to mingw-get.
14
15To start using MinGW, download mingw-get-installer (formerly known as the MinGW automated installer):
16*[http://prdownloads.sf.net/mingw/mingw-get-inst-20101030.exe?download mingw-get-inst-20101030.exe (796kB)]
17
18
19Check the "'''Installing MinGW and MSYS'''" section below for instructions on how to create your ScummVM compilation environment
20
21=== Libraries and Tools needed ===
22
23You don't need to download them right now, we will do that when your MSYS environment is ready to compile these libraries and tools.
24
25* [http://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D NASM] Optional, for faster compile of scalers
26** [http://www.nasm.us/pub/nasm/releasebuilds/2.10rc3/win32/nasm-2.10rc3-win32.zip nasm-2.10rc3-win32.zip (469kB)]
27
28
29* [http://www.libsdl.org/download-1.2.php SDL 1.2].
30** [http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz SDL-devel-1.2.14-mingw32.tar.gz (856kB)]
31
32
33* [http://tdm-gcc.tdragon.net/ TDM-GCC] GCC <4.4.0 because of a bug in g++:
34** [http://prdownloads.sf.net/tdm-gcc/gcc-4.3.3-tdm-1-core.zip?download gcc-4.3.3-tdm-1-core.zip (5.3MB)]
35** [http://prdownloads.sf.net/tdm-gcc/gcc-4.3.3-tdm-1-g++.zip?download gcc-4.3.3-tdm-1-g++.zip (6.0MB)]
36
37
38* [http://www.zlib.net/ zlib]. Optional, for compressed saved games.
39** [http://prdownloads.sourceforge.net/libpng/zlib-1.2.5.tar.gz?download zlib-1.2.5.tar.gz (532kB)]
40
41
42* [http://downloads.xiph.org/releases/ogg/ libogg] and [http://downloads.xiph.org/releases/vorbis/ libvorbis] Optional, for OGG support
43** [http://downloads.xiph.org/releases/ogg/libogg-1.2.2.zip libogg-1.2.2.zip (488kB)]
44** [http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.zip libvorbis-1.3.2.zip (1.7MB)]
45
46
47* [ftp://ftp.mars.org/pub/mpeg/ libmad] Optional, for MP3 support
48** [ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz libmad-0.15.1b.tar.gz (491kB)]
49** [http://merkur.calypse.de/libmad-0.15.1b-optimize.diff Patch to remove a deprecated optimiziation flag not available in newer gcc]
50
51
52* [http://flac.sourceforge.net/download.html FLAC]. Optional, for FLAC support
53** [http://prdownloads.sf.net/flac/flac-1.2.1.tar.gz?download flac-1.2.1.tar.gz (2.0MB)]
54** [http://merkur.calypse.de/flac-1.2.1-mingw.diff Patch for MinGW]
55
56
57* [http://www.zlib.net/ zlib]. Optional, for compressed saved games.
58** [http://prdownloads.sourceforge.net/libpng/zlib-1.2.5.tar.gz?download zlib-1.2.5.tar.gz (532kB)]
59
60
61* [http://libpng.org/pub/png/libpng.html libpng]. Optional, for Broken Sword 2.5-Engine.
62** [http://prdownloads.sourceforge.net/libpng/libpng-1.4.5.tar.gz?download libpng-1.4.5.tar.gz (818kB)]
63
64
65* [http://downloads.xiph.org/releases/theora/ libtheora]. Optional, for Broken Sword 2.5-Engine.
66** [http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz libtheora-1.1.1.tar.gz (2.0MB)]
67
68=== Precompiled libraries ===
69To ease the whole process, a package of all the needed precompiled libraries has been created.
70All you need to do is to download:
71** [http://merkur.calypse.de/scummvm-required-libs-mingw.zip Precompiled libraries]
72After having installed MinGW with MSYS, the additional MSYS tools and a working version of gcc, you can unpack the precompiled libs into your MinGW-directory and then skip to compiling ScummVM directly.
73
74== Installing MinGW and MSYS ==
75
76Both MinGW and MSYS need to be installed and working to compile ScummVM.
77
78* Launch the mingw-get-installer you have downloaded above.
79* To get the newest MinGW-components you can download the latest repository catalogues
80* Accept the license and select an installation directory - the default is recommended, since MinGW may have problems with spaces in directory names
81* Select the needed components: '''C++ Compiler''' and the '''MinGW Developer Toolkit''' (which will include MSYS)
82* Start installation and wait until everything is downloaded and in place.
83* If you see any download errors (blame SourceForge for that) just re-run the installer, it will download and install only the missing files.
84* Start the '''MinGW Shell''' in your Start Menu
85
86== MSYS primer ==
87
88From the developer's webpage: "MSYS or Minimal SYStem is a POSIX and Bourne shell environment use with MinGW. It provides a hand picked set of tools to allow a typical configuration script with Bourne syntax to execute. This allows most of the GNU packages to create a Makefile just from executing the typical configure script which can then be used to build the package using the native MinGW version of GCC".
89
90
91For more information, check the [http://www.mingw.org/wiki/FAQ MinGW FAQ page]
92
93
94MSYS commands can be confusing for people using Windows, as MSYS emulates a Bourne shell environment, which is found in most Unix/Linux distributions. The available commands can be viewed by typing "help" in the command prompt. Help on a specific command is available by typing "help" followed by the command, e.g. "help alias".
95
96
97Note that MSYS uses forward slashes between folder names, not backward slashes, as is the case with Windows. Additionally, some special characters like the space need to be escaped with a backward slash("\"). Drives are mounted to folders, so drive "C:" would be under folder "/c". Therefore, to switch to directory:
98
99 C:\Program Files\Test Folder
100
101we would switch to:
102
103 /c/Program\ Files/Test\ Folder
104
105The basic commands you'll need are:
106
107 cd - changes the current drive and directory
108 pwd - shows the current drive and directory
109 ls - lists files in a folder
110 make - makefile, used to compile projects
111 strip - remove debug information from executable files
112
113Note that if you wish to run a file from the current folder, you need to specify it before the file name, i.e. if you wish to run "test" from the current folder, you should type:
114
115 ./test
116
117== Building the libraries ==
118
119Now, we need to compile the required libraries and tools.
120
121=== Additional MSYS tools ===
122
123In order to download, unpack and patch the needed libraries and tools, we mingw-get the following:
124 mingw-get install msys-wget
125 mingw-get install msys-unzip
126 mingw-get install msys-patch
127
128=== NASM ===
129
130NASM is used for optimized scaler implementations and possibly by some libraries below, so this should be the first to download and install. We just need '''nasm.exe''' and '''ndisasm.exe''' in a directory, found in the PATH-variable. For now, we'll use MinGW's bin-directory:
131
132 wget http://www.nasm.us/pub/nasm/releasebuilds/2.10rc3/win32/nasm-2.10rc3-win32.zip
133 unzip -j nasm-2.10rc3-win32.zip nasm-*/n*asm.exe -d /mingw/bin
134
135=== SDL ===
136
137SDL is already compiled, so we only need to unpack it and put the files in their corresponding places.
138
139You can safely ignore the warnings from tar, since we don't care about file ownership in this case.
140
141 wget http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz
142 tar xvfz SDL-devel-1.2.14-mingw32.tar.gz
143 mkdir /mingw/include/SDL
144 mv SDL-*/include/SDL/* /mingw/include/SDL
145 mv SDL-*/lib/* /mingw/lib
146 mv SDL-*/bin/* /mingw/bin
147 rm -rf SDL-1*
148
149If you want to have a console window, when launching scummvm.exe (the old default), you have to modify sdl-config as follows:
150
151 mv /mingw/bin/sdl-config /mingw/bin/sdl-config-org
152 sed 's/-mwindows//g' /mingw/bin/sdl-config-org >/mingw/bin/sdl-config
153
154=== gcc ===
155
156Since MinGW's g++ starting with version 4.4.0 seems to be buggy ([http://forums.scummvm.org/viewtopic.php?t=9450]), you will need an older version of gcc and g++ (eg. 4.3.3 from [http://tdm-gcc.tdragon.net/ TDM-GCC]) until this bug is fixed:
157 wget http://prdownloads.sf.net/tdm-gcc/gcc-4.3.3-tdm-1-core.zip?download
158 wget http://prdownloads.sf.net/tdm-gcc/gcc-4.3.3-tdm-1-g++.zip?download
159 unzip -o gcc-4.3.3-tdm-1-core.zip -d /mingw
160 unzip -o gcc-4.3.3-tdm-1-g++.zip -d /mingw
161You can check the installed version with
162 g++ --version
163Output should contain ''g++.exe (4.3.3-tdm-1 mingw32) 4.3.3''
164
165=== zlib ===
166
167Issue these commands to download, compile and install the library:
168 wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.5.tar.gz?download
169 tar xvfz zlib-1.2.5.tar.gz
170 cd zlib-*
171 make -f win32/Makefile.gcc BINARY_PATH=/mingw/bin INCLUDE_PATH=/mingw/include LIBRARY_PATH=/mingw/lib install
172 cd ..
173
174=== libogg ===
175
176libogg should be compiled before libvorbis and libFLAC
177
178Issue these commands to download, compile and install the library:
179
180 wget http://downloads.xiph.org/releases/ogg/libogg-1.2.2.zip
181 unzip libogg-1.2.2.zip
182 cd libogg-*
183 ./configure --disable-shared
184 make
185 make install prefix=/mingw
186 cd ..
187
188=== libvorbis ===
189
190Issue these commands to download, compile and install the library:
191
192 wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.zip
193 unzip libvorbis-1.3.2.zip
194 cd libvorbis-*
195 ./configure --disable-shared
196 make
197 make install prefix=/mingw
198 cd ..
199
200=== libmad ===
201
202Issue these commands to download, patch (to remove a deprecated optimizitation flag not available in newer gcc), compile and install the library:
203
204 wget ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz
205 wget http://merkur.calypse.de/libmad-0.15.1b-optimize.diff
206 tar xvfz libmad-0.15.1b.tar.gz
207 patch -i libmad-0.15.1b-optimize.diff -p0
208 cd libmad-*
209 ./configure --disable-shared
210 make
211 make install prefix=/mingw
212 cd ..
213
214=== FLAC ===
215
216Issue these commands to download, patch (see [http://sourceforge.net/tracker/?func=detail&atid=313478&aid=1761712&group_id=13478], [http://lists.xiph.org/pipermail/flac-dev/2008-August/002569.html] and [http://theunknown.com.au/flac-main-cpp75-erreur-%E2%80%98memcmp%E2%80%99-was-not-declared-in-this-scope/]), compile and install the library:
217
218 wget http://prdownloads.sf.net/flac/flac-1.2.1.tar.gz?download
219 wget http://merkur.calypse.de/flac-1.2.1-mingw.diff
220 tar xvfz flac-1.2.1.tar.gz
221 patch -i flac-1.2.1-mingw.diff -p0
222 cd flac-*
223 ./configure --disable-shared
224 make
225 make install prefix=/mingw
226 cd ..
227
228=== libpng ===
229
230Issue these commands to download, compile and install the library:
231 wget http://prdownloads.sourceforge.net/libpng/libpng-1.4.5.tar.gz?download
232 tar xvfz libpng-1.4.5.tar.gz
233 cd libpng-*
234 mv INSTALL INSTALL.txt
235 make -f scripts/makefile.mingw prefix=/mingw install
236 cd ..
237
238=== libtheora ===
239
240Issue these commands to download, compile and install the library:
241
242 wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz
243 tar xvfz libtheora-1.1.1.tar.gz
244 cd libtheora-*
245 ./configure --disable-shared --disable-examples
246 make
247 make install prefix=/mingw
248 cd ..
249
250== Compiling ScummVM ==
251
252Get the latest sources ([http://prdownloads.sourceforge.net/scummvm/scummvm-1.2.1.tar.bz2?download Release 1.2.1] or [http://helllabs.org/scummvm/ Daily Source Snapshot]) and unpack them:
253
254 tar xvfj scummvm-20110101.tar.bz2
255 cd scummvm-*
256
257Edit the configure-script to your liking, ie. what engines you want to use.
258To compile ScummVM, issue the following commands:
259 ./configure --enable-release
260 make
261
262After compilation, you'll end up with a very big scummvm.exe (around 16MB). This is because debug symbols and information are embedded by default in the exe file, making it very big. To remove all the unneeded debug information from the executable, thus reducing its size by about 12MB, go to the folder where the compiled scummvm.exe file is and run the following command:
263
264 strip scummvm.exe
265
266== Ready to go! ==
267
268OK this should be all of it (thankfully), so you should be good to go.