Building IBMulator is a three-step process:
- setup a 64bit MinGW build environment
- build RmlUi
- build IBMulator
NOTE: Do not use folder names with spaces. In this document I'll use C:\msys64 for MSYS2 installation and C:\workspace for source packages.
NOTE: You can copy the shell commands in this document and then paste them in the MSYS shell by pressing the middle mouse button, using Shift+Ins, or clicking the right mouse button and choosing 'paste'.
We will use mingw-w64 (mingw-w64.org) under MSYS2 (www.msys2.org)
- Go to the MSYS2 website, download the x86_64 package and follow its installation instructions.
- Launch the MSYS2 MSYS shell from the
MSYS2 64bit
folder and install the toolchain:
pacman -S mingw-w64-x86_64-binutils mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake make autoconf automake libtool git
- Install the libraries needed by RmlUi and IBMulator:
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew mingw-w64-x86_64-libsamplerate mingw-w64-x86_64-freetype mingw-w64-x86_64-lzo2
You can compile IBMulator with dynamic or static linking; see below for more info on the two versions. I suggest static linking to get a more convenient and smaller package. The following instructions assume static linking.
RmlUi is a C++ GUI toolkit based on the HTML
and CSS standards.
IBMulator requires version 5.1 of this library but unfortunately it doesn't
compile with current versions of MSYS2. For this reason we are going to use my
patched fork.
Launch the MSYS2 MINGW64 shell from the MSYS2 64bit
folder (you should
read MINGW64 on the command line) and:
- Move inside your workspace:
cd /c/workspace
- Clone the repo:
git clone https://github.com/barotto/RmlUi
- Switch to the correct branch:
cd RmlUi && git switch 5.1-fix
- Create and move inside the build directory:
mkdir build && cd build
- Create the Makefile with cmake:
cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/mingw64/x86_64-w64-mingw32 -DBUILD_SHARED_LIBS=OFF
(for dynamic linking remove-DBUILD_SHARED_LIBS=OFF
) - Build and install:
make -j$(nproc) && make install
Open the MSYS2 MINGW64 shell and:
- Move inside your workspace:
cd /c/workspace
- Clone the repo:
git clone https://github.com/barotto/IBMulator.git
- Move inside the IBMulator directory:
cd IBMulator
- run autoreconf (only once, not needed if you build again):
autoreconf --install
- Configure IBMulator:
./configure --enable-static --prefix=/c/workspace/IBMulator/release
(for dynamic linking remove--enable-static
)
use the--help
option to see the available build options;
see below for more info about the--prefix
option. - Build:
make -j$(nproc)
- Install (only if you used the
--prefix
option):
make install
If you followed the instructions you'll find IBMulator inside the release
folder. You can now move and rename the release
package.
The installation process is not a Windows program installation. Its purpose is to organize the executable and its assets inside a folder from where the program can run.
This is the needed directory structure:
[install dir]
├ bin
│ ├ ibmulator.exe
│ └ [DLLs...] (only for dynamic linking without PATH variable modification)
└ share
└ ibmulator
└ [assets...]
To automatically organize this structure and copy the files use the --prefix
configure option and the make install
command after make
.
You'll need to use an absolute path without spaces. So, for example, to
create a release package inside the source directory:
--prefix="C:\workspace\IBMulator\release"
You are free to move this package inside C:\Program Files
, your desktop, or
any other folder you like, as IBMulator uses relative paths to load its assets.
If you opted for the statically linked build you are now ready to use IBMulator.
If you opted for the dynamically linked build you now need to make the needed DLLs available to ibmulator.exe. You have two options:
- modify your PATH system variable
- copy the DLLs inside the ibmulator.exe folder.
Assuming that you've installed MSYS2 in C:\msys64, append this to your PATH
environment variable:
C:\msys64\mingw64\bin;C:\msys64\mingw64\x86_64-w64-mingw32\bin
How to modify a system variable depends on the Windows version you are using. For example: System->Advanced System Settings->Advanced tab->Environment Variables.
Use Dependency Walker to determine the up to date list of DLLs the executable
depends on and copy them inside the IBMulator's bin
folder.
Install the GDB debugger:
pacman -S gdb
Use dynamic linking and build a debug version of the executable:
- configure RmlUi with
-DCMAKE_BUILD_TYPE=Debug
- configure IBMulator with
--enable-debug
You don't need to install the program in order to debug it, just run
ibmulator.exe inside the src
directory.
If you don't want to interact with gdb, you can use an IDE like Eclipse CDT.
Sometimes using gdb is too inconveninent and slow and the only thing you want is
a backtrace. A useful tool to catch and analyze segmentation faults is
catchsegv
, which is included in the drmingw
package:
pacman -S mingw-w64-x86_64-drmingw
To catch a segmentation fault and obtain a backtrace run:
catchsegv src/ibmulator.exe