Compilar PhysicFS con MinGW

PhysicsFS es una librería que permite acceder al contenido de archivos .zip transparentemente como si fueran parte de nuestro sistema de archivos. Allegro 5 cuenta con un addon para usar PhysicsFS en tus programas de Allegro. En posts anteriores describí la forma de compilar la versión de Allegro para Windows usando MinGW, en esa ocasión no compilamos PhysicsFS para Windows para poder usarla con Allegro pero ahora tengo un proyecto de Allegro que requiere usar este addon y por lo tanto debemos compilar la librería usando MinGW.

Compilar PhysicsFS para Windows no debería ser difícil ya que usa CMake, por lo que el archivo de toolchain que usamos en posts anteriores debería sernos útil:

monstruosoft@debian:~/build/physfs-3.0.2$ mkdir build-mingw32
monstruosoft@debian:~/build/physfs-3.0.2$ cd build-mingw32/
monstruosoft@debian:~/build/physfs-3.0.2/build-mingw32$ export PKG_CONFIG_LIBDIR=/home/monstruosoft/mingw32-i686/lib/pkgconfig/
monstruosoft@debian:~/build/physfs-3.0.2/build-mingw32$ cmake -DCMAKE_TOOLCHAIN_FILE=~/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=/home/monstruosoft/mingw32-i686/ ..
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc -- works
-- PhysicsFS will build with the following options:
--   ZIP support: enabled
--   7zip support: enabled
--   GRP support: enabled
--   WAD support: enabled
--   HOG support: enabled
--   MVL support: enabled
--   QPAK support: enabled
--   SLB support: enabled
--   VDF support: enabled
--   ISO9660 support: enabled
--   Build static library: enabled
--   Build shared library: enabled
--   Build stdio test program: enabled
--     Use readline in test program: disabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/monstruosoft/build/physfs-3.0.2/build-mingw32
monstruosoft@debian:~/build/physfs-3.0.2/build-mingw32$ make -j 4
Scanning dependencies of target physfs-static
Scanning dependencies of target physfs
...
[ 95%] Built target physfs
[100%] Built target test_physfs
monstruosoft@debian:~/build/physfs-3.0.2/build-mingw32$ make install
[ 47%] Built target physfs-static
[ 95%] Built target physfs
[100%] Built target test_physfs
Install the project...

Ahora simplemente debemos recompilar Allegro con el MinGW para generar el addon de PhysicsFS:

monstruosoft@debian:~/build/physfs-3.0.2/build-mingw32$ cd ..
monstruosoft@debian:~/build/physfs-3.0.2$ cd ..
monstruosoft@debian:~/build$ cd allegro-5.2.5.0/
monstruosoft@debian:~/build/allegro-5.2.5.0$ cd build-mingw32/
monstruosoft@debian:~/build/allegro-5.2.5.0/build-mingw32$ cmake -DCMAKE_TOOLCHAIN_FILE=~/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=/home/monstruosoft/mingw32-i686/ ..
...
-- Found PhysFS: /home/monstruosoft/mingw32-i686/bin/libphysfs.dll  
-- Found PHYSFS: /home/monstruosoft/mingw32-i686/bin/libphysfs.dll  
-- Could NOT find ZLIB (missing:  ZLIB_LIBRARY) (found version "1.2.8")
-- Performing Test PHYSFS_IMPLICIT_ZLIB
-- Performing Test PHYSFS_IMPLICIT_ZLIB - Success
...
monstruosoft@debian:~/build/allegro-5.2.5.0/build-mingw32$ make -j 4
monstruosoft@debian:~/build/allegro-5.2.5.0/build-mingw32$ make install

Ahora podemos usar PhysicsFS en nuestros programas de Allegro 5.

Compilar programas para Windows desde Linux – Parte 1

¿Eres un usuario de Linux y disfrutas haciendo tus programitas en C o C++ pero quieres compartirlos con el resto del mundo que seguramente usa Windows?. Compartirles el código es una posibilidad pero el usuario promedio no sabría qué hacer con él así que tus opciones se reducen a entregarles un ejecutable listo para usar en Windows. Por suerte, compilar tus programas para Windows es relativamente fácil en Linux, sobre todo si alguna vez usaste MinGW en Windows. MinGW es, por así decirlo, el gcc para Windows. MinGW ofrece compiladores para C y C++ (entre otros) que generan archivos ejecutables .exe para Windows así que, como te imaginarás, solamente tenemos que instalar MinGW para poder usarlo para generar ejecutables para Windows desde nuestra distro de Linux. Para instalar MinGW en Debian Stretch, basta con instalar el paquete mingw-w64 desde el gestor de paquetes.

Read More