<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Installation on Windows using msys2 (revised wiki article)</title>
		<link>http://www.allegro.cc/forums/view/616828</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 30 Mar 2017 20:57:17 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, so I decided to revise the wiki article about MSYS2 (how to install Allegro5 while getting started from scratch).<br />Since I cannot edit the wiki currently (didn&#39;t know, sorry), I&#39;m posting it here. I won&#39;t bother further fixing the formatting for now. See the bottom for notes about a (I think) better CMake command.</p><h4>I) Install and apply latest updates to MSYS2 base system</h4><p>

</p><ol><li><p>Go to www.msys2.org and download the installer. Pick the msys2-x86_64-... variant for a 64 bit system and the i686 variant for a 32 bit system.</p><br /></li><li><p>Run the installer. Select a path containing only plain old ASCII characters (no accents) and no spaces (!) to install to.</p><br /></li><li><p>Tick &quot;Run msys2 now&quot; (or rather, don&#39;t uncheck it).</p><br /></li><li><p>In the terminal window that opens, run the command <tt>pacman -Syu</tt> and confirm the update when necessary. </p><br /></li><li><p>Close the terminal window if requested, confirm if necessary.</p><br /></li><li><p>From your start menu, open the &quot;MSYS2 MSYS&quot; shell again (all 3 variants can be found under &quot;MSYS 64 bit&quot; (or &quot;MSYS 32 bit&quot; respectively)</p><br /></li><li><p>In the terminal window, run the command <tt>pacman -Su</tt> and confirm when necessary</p></li></ol><p>Type &quot;exit&quot; to exit the MSYS2-shell<br />You now have an up-to-date MSYS2 base system.</p><h4>II) Install the C/C++ compiler</h4><p>
I&#39;ll assume you use a 64 bit system. If you use a 32 bit system, substitute x86_64 with i686 in all the <tt>pacman</tt> invocations that follow.</p><ol><li><p>Open the &quot;MSYS2 MinGW 64-bit&quot; shell from the start menu (32-bit on a 32 bit system). This will be the one you&#39;ll be working with from now on. </p><br /></li><li><p>Run <tt>pacman -S mingw-w64-x86_64-gcc</tt> to install a C/C++ compiler. This will pull in quite some other packages.
</p></li><li><p>Run <tt>pacman -S mingw-w64-x86_64-gdb</tt> to install a debugger.</p></li></ol><p>You now have a working C/C++ compiler and debugger.</p><h4>III) Install Allegro</h4><p>
You have two options here. The easiest way to get started is to just install the Allegro5 distribution that comes via msys2&#39;s packages. This is usually lagging a bit behind the current Allegro version (they do have 5.2.2 right now) and only provides shared libraries. This should be okay for development, but it&#39;s usually not appropriate when you want to release your project.</p><p>You can also compile the latest version of Allegro5 yourself, which also gives you better control over the type of binaries you want (for example, a monolith dll). See below for that.</p><p>Both variants should best be thought about as being mutually exclusive.</p><p>Note that there are also official Allegro5 binaries (follow the link &quot;Allegro 5.2 binary packages&quot; on <a href="http://liballeg.org/download.html">http://liballeg.org/download.html</a>). <br />These are a bit more versatile (e.g. providing static variants of the dependencies, too), but usually depend on a specific compiler version. Using them should be straightforward,<br />but you need to confirm that the compiler you&#39;ve installed via MSYS2 is (still) compatible. </p><h5>A) From MSYS2&#39;s packages</h5><p>

To install the Allegro 5 package from the msys2 packages, just enter:<br /><tt>pacman -S mingw-w64-x86_64-allegro</tt></p><p>You will see messages about what dependency packages to install in order to use certain addons. <br />It looks like that on my system:
</p><pre>
mingw-w64-x86_64-dumb: allegro_audio
mingw-w64-x86_64-flac: allegro_audio
mingw-w64-x86_64-opusfile: allegro_audio
mingw-w64-x86_64-freetype: allegro_font
mingw-w64-x86_64-libjpeg-turbo: allegro_image
mingw-w64-x86_64-libpng: allegro_image
mingw-w64-x86_64-libvorbis: allegro_audio
mingw-w64-x86_64-openal: allegro_audio
mingw-w64-x86_64-physfs: allegro_physfs
</pre><p>
If you need the functionality, you can install any of them by <tt>pacman -S</tt> ing them. To start out, I&#39;d recommend to install at least freetype, libjpeg-turbo and libpng.<br />So you would do:<br /><tt>pacman -S mingw-w64-x86_64-freetype</tt><br /><tt>pacman -S mingw-w64-x86_64-libpng</tt><br /><tt>pacman -S mingw-w64-x86_64-libjpeg-turbo</tt></p><p>Now you can compile a simple Allegro5 program (for example, excamera.c) by running the following command in a &quot;MSYS2 64 bit&quot; terminal window<br /><tt>gcc ex_camera.c -Wall -o camera -lallegro -lallegro_font -lallegro_color -lallegro_primitives</tt></p><p>(Note: In case of ex_camera, you will need common.c from the Allegro5 examples directory as well (these are not included in the MSYS2 package, I&#39;ve just picked them as an example))<br />This should just work.</p><h5>B) Compiling Allegro from source</h5><p>

</p><ol><li><p>Remove the MSYS2-supplied package if installed <br />If you want to compile Allegro5 yourself and have the Allegro5 package (supplied by MSYS2) installed, it is better to remove the MSYS2 allegro5 package beforehand by issuing <br /><tt>pacman -R mingw-w64-x86_64-allegro</tt>.<br />You can check which packages you have installed by running <br /><tt>pacman -Q</tt>. That means <br /><tt>pacman -Q | grep allegro</tt> <br />should print something if their package is installed.<br />You can, of course, always reinstall this version.
</p></li><li><p>Install make, cmake, git, and pkg-config:
</p><pre>pacman -S make
pacman -S mingw-w64-x86_64-cmake
pacman -S git
pacman -S mingw-w64-x86_64-pkg-config</pre><p>
</p></li><li><p>
Install any of the Allegro5 dependencies you want/need (if you haven&#39;t already):
</p><pre>
pacman -S mingw-w64-x86_64-freetype
pacman -S mingw-w64-x86_64-libpng
pacman -S mingw-w64-x86_64-libjpeg-turbo
pacman -S mingw-w64-x86_64-libvorbis  
pacman -S mingw-w64-x86_64-flac       
pacman -S mingw-w64-x86_64-physfs     
pacman -S mingw-w64-x86_64-dumb       
pacman -S mingw-w64-x86_64-libtheora  
</pre><p>
</p></li><li><p>Clone the Allegro5 repository<br />Run this from a (preferably empty) directory of your choice:
</p><pre>git clone <a href="https://github.com/liballeg/allegro5.git">https://github.com/liballeg/allegro5.git</a></pre><p>
(no link emphasis intended)<br />It will create an allegro5 folder with the Allegro5 source code inside.
</p></li><li><p>Configure Allegro5 (monolith variant - one dll)<br />Run this just outside the allegro5 folder obtained by calling git:
</p><pre>mkdir build_allegro_monolith
cd build_allegro_monolith
cmake G&quot;MSYS Makefiles&quot; -D&quot;CMAKE_SYSTEM_PREFIX_PATH:PATH=/mingw64/x86_64-w64-mingw32&quot; -DWANT_MONOLITH=on ../allegro5</pre><p>

(for 32 bit systems, use
</p><pre>
cmake -G&quot;MSYS Makefiles&quot; -D&quot;CMAKE_SYSTEM_PREFIX_PATH:PATH=/mingw32/i686-w64-mingw32&quot; -DWANT_MONOLITH=on ../allegro5</pre><p>
instead)</p><p>The part about CMAKE_SYSTEM_PREFIX_PATH is needed in order to find the DirectX libraries shipping with MSYS2.
</p></li><li><p>
Build Allegro5
</p><pre>
make 
make install</pre><p>

<tt>make install</tt> should automatically pick /mingw64, i.e. C:\msys64\mingw64 as the installation prefix (or msys32/mingw32 for a 32 bit system)
</p></li></ol><p>
</p><h4>IV) Running programs you built outside the MSYS2 terminal</h4><p>

When you want to run programs build with MSYS2 outside your terminal window, your system needs to be able to find the DLLs that reside in /mingw64/bin (for a 64 bit installation). So you&#39;ll need to add C:\msys64\mingw64\bin to your system PATH if C:\msys64 is where you installed msys2. You should take care that no other similar installation is on the path before this one. </p><p>You may find that a console window is opened even when running your program from outside the terminal. To get rid of it, pass -mwindows as a compiler flag, e.g.<br /><tt>gcc ex_camera.c -Wall -o camera -mwindows -lallegro -lallegro_font -lallegro_color -lallegro_primitives</tt><br />or <br /><tt>gcc ex_camera.c -Wall -o camera -mwindows -lallegro_monolith</tt></p><h4>Notes</h4><p>
The current article on the wiki suggests to install into /mingw64/x86_64-w64-mingw32 by setting this as <tt>CMAKE_INSTALL_PREFIX</tt><br />I don&#39;t think that&#39;s a good idea since this seems to be a directory for internal use only. <br />However, when omitting it, CMake won&#39;t find the DirectX libraries shipping with MSYS2. <br />Therefore, I&#39;d suggest to adapt the CMAKE_SYSTEM_PREFIX_PATH instead. <br />This will make CMake find the DirectX libs without having to install to <br />/mingw64/x86_64-w64-mingw32.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Polybios)</author>
		<pubDate>Thu, 30 Mar 2017 20:57:17 +0000</pubDate>
	</item>
</rss>
