User avatar
amaipaipai
Posts: 4
Joined: Fri Jul 21, 2017 11:16 am

Compiling MAME Windows binary on a Debian Linux

Mon Sep 18, 2017 1:54 am

This is a small description on how to compile a windows binary on a Linux machine. (cross-compiling)
To compile mame binary over windows it's time consuming, on my machine it takes about 2:48 hours to compile the 0.189 source code with make -j16.

Code: Select all

Windows 10 64 Bit 1703 (15063.608) GIGABYTE AM3+ ATX GA-990FXA-UD5 R5 AMD FX-8350 Vishera Corsair Vengeance 16GB (2x8GB) 1866MHz DDR3 CL10 Red CMZ16GX3M2A1866C10R
This is the TimeMem info:

Code: Select all

Linking mame64.exe... Exit code : 0 Elapsed time : 8944.14 Kernel time : 12.86 (0.1%) User time : 2.28 (0.0%) page fault # : 8360 Working set : 18768 KB Paged pool : 100 KB Non-paged pool : 8 KB Page file size : 14776 KB
8944/3600 = 2:48hrs

Over Linux is a different story, compiling the exact same source with the same computer, with the same "make -j16" it takes only 24 minutes:

Code: Select all

Linking mame64.exe... real 24m4,513s user 157m24,328s sys 10m5,328s
I'm using Debian 9.1 (Stretch) and this is what you have to do:
1. Download the tools, this will install all the necessary software and aptitude will handle the rest.

Code: Select all

sudo aptitude install git build-essential libsdl2-dev libsdl2-ttf-dev libfontconfig-dev qt5-default binutils-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-base gcc-mingw-w64-x86-64 gobjc++-mingw-w64 mingw-w64 mingw-w64-common mingw-w64-tools mingw-w64-x86-64-dev win-iconv-mingw-w64-dev
2. Now you need to put the correct "gcc, ar, and g++" at the right place, failing to do this will return a bunch of errors, use the posix versions.

Code: Select all

sudo ln -s /usr/bin/x86_64-w64-mingw32-g++-posix /usr/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-g++ sudo ln -s /usr/bin/x86_64-w64-mingw32-gcc-ar-posix /usr/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc-ar sudo ln -s /usr/bin/x86_64-w64-mingw32-gcc-posix /usr/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc
3. Set the MINGW64 variable with:

Code: Select all

export MINGW64="/usr/x86_64-w64-mingw32"
You can add this to your $PATH in your .bashrc

4. This are the changes I've made in the makefile

Code: Select all

PTR64 = 1 OPTIMIZE = 3 TARGETOS = windows CROSS_BUILD = 1
That's it.
This should work with other Linux distro. Don't forget to do the following command at the end:

Code: Select all

strip mame64.exe
Good luck.

Return to “MAME Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest