# Building mz800emu on Windows (64-bit)

I use MSYS2 to compile the program for Windows (64 bit). Here is a step-by-step guide to install the environment, libraries, and create a distribution directory with the `mz800emu` program:

## 1) MSYS2

Download and install the MSYS2 environment from [https://www.msys2.org/](https://www.msys2.org/)

Immediately after installation, I recommend setting an exception in your antivirus system for the directory structure `C:\msys64`.

MSYS2 contains several pre-built environments. We will use the **MSYS2 MINGW64** environment to build `mz800emu`. I recommend pinning its icon to your desktop and choosing a more readable font for the terminal.

Your MSYS2 home directory is accessible from Windows as `C:\msys64\home\<username>`.

## 2) Environment update

Not only right after installation — it's always a good idea to keep your system packages up to date.

Synchronize the package database:

```sh
pacman -Syy
```

Then update it:

```sh
pacman -Syuu
```

> Please note that after the first installation you will probably need to repeat these steps several times.  
> I recommend creating a file `do_update.sh` in your home directory and using it to perform the update.

## 3) Development packages

### Base development packages

```sh
pacman -S base-devel mingw-w64-x86_64-toolchain subversion doxygen
```

### File manipulation and console editors (optional)

```sh
pacman -S mc nano vim
```

### Packages necessary for mz800emu

```sh
pacman -S mingw-w64-x86_64-sdl3 mingw-w64-x86_64-sdl3-image
pacman -S mingw-w64-x86_64-glib2 mingw-w64-x86_64-curl mingw-w64-x86_64-minizip-ng
```

## 4) Download latest mz800emu code

```sh
svn checkout https://svn.code.sf.net/p/mz800emu/code/branches/2.0.x-preview
cd 2.0.x-preview
```

> `<n>` - the value determines the maximum number of threads that will be used during compilation

```sh
make -j <n>
```

## 4a) Compile locale files (optional)

If you want translations (Czech, German, Japanese, etc.), you need to compile `.po` files into `.mo` binary catalogs. The build system will remind you if `.mo` files are missing.

```sh
make i18n-compile-all
```

## 5) Running and distribution

If the program was successfully compiled, you can run it directly from the MSYS2 environment:

```sh
./mz800emu.exe
```

If you want to run the program separately in Windows without the presence of the MSYS2 environment, you need to create a distribution directory:

```sh
make dist
```

All necessary files will be uploaded to the `./dist` directory. The `mz800emu` program is now compiled to run without a text console by default.

If you want to run the program with a text console, create a Windows shortcut to the `mz800emu.exe` file in the `./dist` directory and add the `--console` parameter to the run.
