To compile MAME, you need a C++17 compiler and runtime library. Wesupport building with GCC version 7.2 or later and clang version 6 orlater. MAME should run with GNU libstdc++ version 7.2 or later.
Whenever you are changing build parameters, (such as switching betweena SDL-based build and a native Windows renderer one, or adding toolsto the compile list) you need to run a make REGENIE=1 to allow thesettings to be regenerated. Failure to do this will cause you verydifficult to troubleshoot problems.
If you want to add various additional tools to the compile, such asCHDMAN, add a TOOLS=1 to your make statement, likemake REGENIE=1 TOOLS=1
You can do driver specific builds by using SOURCES=<driver> in yourmake statement. For instance, building Pac-Man by itself would bemake SOURCES=src/mame/drivers/pacman.cpp REGENIE=1 including thenecessary REGENIE for rebuilding the settings.
Speeding up the compilation can be done by using more cores from yourCPU. This is done with the -j parameter. Note: a good number tostart with is the total number of CPU cores in your system plus one.An excessive number of concurrent jobs may increase compilation time.The optimal number depends on many factors, including number of CPUcores, available RAM, disk and filesystem performance, and memorybandwidh. For instance, make -j5 is a good starting point on asystem with a quad-core CPU.
Debugging information can be added to a compile using SYMBOLS=1though most users will not want or need to use this. This increasescompile time and disk space used.
On January 11, 2021, the iPad mini 2 received the iOS 12 update, iOS 12.5.1. The iPad mini 2 cannot go over iOS 12 due to hardware issues and software limits that will not be able to handle the features of iOS 13 and 14, due to the iPad mini 2’s Apple A7 chip. This also renders Bootcamp support with VMware Fusion 10 unusable. Upon further digging, I found that my disk0 is Bootcamp and my disk1 is Macintosh HD. It seems to me that a switch occurs for some unknown reason, or possibly that the Bootcamp partition is being installed in the same partition or disk as the EFI partition.
Putting all of these together, we get a couple of examples:
Rebuilding MAME for just the Pac-Man driver, with tools, on a quad-core(e.g. i5 or i7) machine:
Rebuilding MAME on a dual-core (e.g. i3 or laptop i5) machine:
MAME for Windows is built using the MSYS2 environment. You will need Windows 7or later and a reasonably up-to-date MSYS2 installation. We strongly recommendbuilding MAME on a 64-bit system. Instructions may need to be adjusted for32-bit systems.
A pre-packaged MSYS2 installation including the prerequisites for buildingMAME can be downloaded from the MAME Build Tools page.
After initial installation, you can update the MSYS2 environment using thepacman (Arch package manage) command.
By default, MAME will be built using native Windows OS interfaces forwindow management, audio/video output, font rendering, etc. If you want touse the portable SDL (Simple DirectMedia Layer) interfaces instead, you canadd OSD=sdl to the make options. The main emulator binary will have an
sdl
prefix prepended (e.g.sdlmame.exe
). Youwill need to install the MSYS2 packages for SDL 2 version 2.0.3 or later.By default, MAME will include the native Windows debugger. To also includethe portable Qt debugger, add USE_QTDEBUG=1 to the make options. Youwill need to install the MSYS2 packages for Qt 5.
You may also build MAME using a standard MSYS2 installation and adding the toolsneeded for building MAME. These instructions assume you have some familiaritywith MSYS2 and the pacman package manager.
Install the MSYS2 environment from the MSYS2 homepage.
Download the latest version of the
mame-essentials
package from theMAME package repository and install itusing the pacman command.Add the
mame
repository to/etc/pacman.conf
using/etc/pacman.d/mirrorlist.mame
for locations.Install packages necessary to build MAME. At the very least, you’ll need
bash
,git
,make
.For 64-bit builds you’ll need
mingw-w64-x86_64-gcc
andmingw-w64-x86_64-python
.For 32-bit builds you’ll need
mingw-w64-i686-gcc
andmingw-w64-i686-python
.For debugging you may want to install
gdb
.To link using the LLVM linker (generally much faster than the GNU linker),you’ll need
mingw-w64-x86_64-lld
andmingw-w64-x86_64-libc++
for64-bit builds, ormingw-w64-i686-lld
andmingw-w64-i686-libc++
for32-bit builds.To build against the portable SDL interfaces, you’ll need
mingw-w64-x86_64-SDL2
andmingw-w64-x86_64-SDL2_ttf
for 64-bit builds,ormingw-w64-i686-SDL2
andmingw-w64-i686-SDL2_ttf
for 32-bit builds.To build the Qt debugger, you’ll need
mingw-w64-x86_64-qt5
for 64-bitbuilds, ormingw-w64-i686-qt5
for 32-bit builds.To build the HTML user/developer documentation, you’ll need
mingw-w64-x86_64-librsvg
,mingw-w64-x86_64-python-sphinx
,mingw-w64-x86_64-python-sphinx_rtd_theme
andmingw-w64-x86_64-python-sphinxcontrib-svg2pdfconverter
for a 64-bit MinGWenvironment (or alternativelymingw-w64-i686-librsvg
,mingw-w64-i686-python-sphinx
,mingw-w64-i686-python-sphinx_rtd_theme
andmingw-w64-x86_64-python-sphinxcontrib-svg2pdfconverter
a 32-bit MinGWenvironment).To generate API documentation from source, you’ll need
doxygen
.If you plan to rebuild bgfx shaders and you want to rebuild the GLSL parser,you’ll need
bison
.For 64-bit builds, open MSYS2 MinGW 64-bit from the start menu, and setup the environment variables
MINGW64
to/mingw64
andMINGW32
to anempty string (e.g. using the command export MINGW64=/mingw64 MINGW32= inthe Bash shell).For 32-bit builds, open MSYS2 MinGW 32-bit from the start menu, and setup the environment variables
MINGW32
to/mingw32
andMINGW64
to anempty string (e.g. using the command export MINGW32=/mingw32 MINGW64= inthe Bash shell).
For example you could use these commands to ensure you have the packages youneed to compile MAME, omitting the ones for configurations you don’t plan tobuild for or combining multiple pacman commands to install more packages atonce:
You could use these commands to install the current version of themame-essentials package and add the MAME package repository to your pacmanconfiguration:
You can generate Visual Studio 2017 projects using make vs2017. Thesolution and project files will be created in
build/projects/windows/mame/vs2017
by default (the name of thebuild
folder can be changed using theBUILDDIR
option). This will alwaysregenerate the settings, so REGENIE=1 is not needed.Adding MSBUILD=1 to the make options will build build the solution usingthe Microsoft Build Engine after generating the project files. Note that thisrequires paths and environment variables to be configured so the correctVisual Studio tools can be located.
MAME can only be compiled with the Visual Studio 15.7.6 tools. Bugs in newerversions of the Microsoft Visual C/C++ compiler prevent it from compilingMAME.
The MSYS2 environment is still required to generate the project files, convertbuilt-in layouts, compile UI translations, etc.
MSYS2 uses the pacman tool from Arch Linux for package management. There is apage on the Arch Linux wikiwith helpful information on using the pacman package management tool.
The MSYS2 environment includes two kinds of tools: MSYS2 tools designed to workin a UNIX-like environment on top of Windows, and MinGW tools designed to workin a more Windows-like environment. The MSYS2 tools are installed in/usr/bin
while the MinGW tools are installed in /ming64/bin
and/or/mingw32/bin
(relative to the MSYS2 installation directory). MSYS2 toolswork best in an MSYS2 terminal, while MinGW tools work best in a Microsoftcommand prompt.
The most obvious symptom of this is that arrow keys don’t work in interactiveprograms if you run them in the wrong kind of terminal. If you run MinGW gdb orpython from an MSYS2 terminal window, command history won’t work and it may notbe possible to interrupt an attached program with gdb. Similarly it may be verydifficult to edit using MSYS2 vim in a Microsoft command prompt window.
MAME is built using the MinGW compilers, so the MinGW directories are includedearlier in the PATH
for the build environments. If you want to use aninteractive MSYS2 program from an MSYS2 shell, you may need to type the absolutepath to avoid using the MinGW equivalent instead.
MSYS2 gdb may have issues debugging MinGW programs like MAME. You may getbetter results by installing the MinGW version of gdb and running it from aMicrosoft command prompt window to debug MAME.
GNU make supports both POSIX-style shells (e.g. bash) and the Microsoft cmd.exeshell. One issue to be aware of when using the cmd.exe shell is that thecopy
command doesn’t provide a useful exit status, so file copy tasks canfail silently.
It is not possible to cross-compile a 32-bit version of MAME using 64-bit MinGWtools on Windows, the 32-bit MinGW tools must be used. This causes issues dueto the size of MAME. It is not possible to link a full 32-bit MAME buildincluding the SDL OS-dependent layer and the Qt debugger. GNU ld and lld willboth run out of memory, leaving an output file that doesn’t work. It’s alsoimpossible to make a 32-bit build with full local variable symbols. GCC may runout of memory, and certain source files may exceed the limit of 32,768 sectionsimposed by the PE/COFF object file format.
You’ll need a few prerequisites from your Linux distribution. Make sure you getSDL2 2.0.4 or later as earlier versions are buggy:
Compilation is exactly as described above in All Platforms.
To build the HTML user/developer documentation, you’ll need Sphinx, as well asthe theme and the SVG converter:
The HTML documentation can be built with this command:
You’ll need a few prerequisites from your Linux distribution. Make sure you getSDL2 2.0.4 or later as earlier versions are buggy:
Compilation is exactly as described above in All Platforms. Note the UbuntuLinux modifies GCC to enable the GNU C Library “fortify source” feature bydefault, which may cause issues compiling MAME (see Known Issues).
You’ll need a few prerequisites from your distro:
Compilation is exactly as described above in All Platforms.
You’ll need a few prerequisites to get started. Make sure you’re on OS X 10.14Mojave or later for Intel Macs or macOS 11.0 Big Sur for Apple Silicon. You will need SDL2 2.0.4 or later for Intel or SDL2 2.0.14 on Apple Silicon.
Install Xcode from the Mac App Store or ADC (AppleID required).
To find the corresponding Xcode for your MacOS release please visit xcodereleases.com to find the latest version of Xcode available to you.
Launch Xcode. It will download a few additional prerequisites. Let thisrun through before proceeding.
Once that’s done, quit Xcode and open a Terminal window
Type xcode-select --install to install additional tools necessary for MAME (also available as a package on ADC).
Next you’ll need to get SDL2 installed.
Go to this site and download the Mac OS X .dmg file
If the .dmg doesn’t auto-open, open it
Click “Macintosh HD” (your Mac’s hard disk) in the Locations sidebar of a Finder window, then open the Library folder and drag the SDL2.framework folder from the SDL disk image into the Frameworks folder. You will have to authenticate with your user password.
Lastly to begin compiling, use Terminal to navigate to where you have the MAMEsource tree (cd command) and follow the normal compilation instructions fromabove in All Platforms.
First, download and install Emscripten 1.37.29 or later by following theinstructions at the official site
Once Emscripten has been installed, it should be possible to compile MAMEout-of-the-box using Emscripten’s emmake tool. Because a full MAME compileis too large to load into a web browser at once, you will want to use theSOURCES parameter to compile only a subset of the project, e.g. (in the mamedirectory):
The SOURCES parameter should have the path to at least one driver .cppfile. The make process will attempt to locate and include all dependenciesnecessary to produce a complete build including the specified driver(s).However, sometimes it is necessary to manually specify additional files (usingcommas) if this process misses something. e.g.
The value of the SUBTARGET parameter serves only to differentiate multiplebuilds and need not be set to any specific value.
Emscripten supports compiling to WebAssembly with a JavaScript loader instead ofall-JavaScript, and in later versions this is actually the default. To forceWebAssembly on or off, add WEBASSEMBLY=1 or WEBASSEMBLY=0 to the makecommand line.
Other make parameters can also be used, e.g. -j for parallel compilation, asdescribed earlier.
When the compilation reaches the emcc phase, you may see a number of'unresolved symbol' warnings. At the moment, this is expected forOpenGL-related functions such as glPointSize. Any others may indicate that anadditional dependency file needs to be specified in the SOURCES list.Unfortunately this process is not automated and you will need to search thesource tree to locate the files supplying the missing symbols. You may also beable to get away with ignoring the warnings if the code path referencing them isnot used at run-time.
If all goes well, a .js file will be output to the current directory. Thisfile cannot be run by itself, but requires an HTML loader to provide it with acanvas to draw to and to pass in command-line parameters. TheEmularity project provides such a loader.
There are example .html files in that repository which can be edited topoint to your newly compiled MAME .js file and pass in whatever parametersyou desire. You will then need to place all of the following on a web server:
The compiled MAME .js file
The compiled MAME .wasm file if using WebAssembly
The .js files from the Emularity package (loader.js, browserfs.js,etc.)
A .zip file with the ROMs for the MAME driver you would like to run (ifany)
Any software files you would like to run with the MAME driver
An Emularity loader .html modified to point to all of the above
You need to use a web server instead of opening the local files directly due tosecurity restrictions in modern web browsers.
If the result fails to run, you can open the Web Console in your browser to seeany error output which may have been produced (e.g. missing or incorrect ROMfiles). A “ReferenceError: foo is not defined” error most likely indicates thata needed source file was omitted from the SOURCES list.
Compiling the documentation will require you to install several packagesdepending on your operating system.
On Debian/Ubuntu flavors of Linux, you’ll need python3-sphinx/python-sphinxand the python3-pip/python-pip packages, depending on whether you’re usingPython 3 or Python 2:
or:
You’ll then need to install the SVG handler:
or:
depending on whether you’re using Python 3 or Python 2.
If you intend on making a PDF via LaTeX, you’ll need to install a LaTeXdistribution such as TeX Live:
From this point, you can do make html or make latexpdf from the docsfolder to generate the output of your choice. Typing make by itself willtell you all available formats. The output will be in the docs/build folder ina subfolder based on the type chosen (e.g. make html will createdocs/build/html containing the output).
This section summarises some of the more useful options recognised by the mainmakefile. You use these options by appending them to the make command,setting them as environment variables, or adding them to your prefix makefile.Note that in order to apply many of these settings when rebuilding, you need toset REGENIE=1 the first time you build after changing the option(s). Alsonote that GENie does not automatically rebuild affected files when you changean option that affects compiler settings.
Name of a makefile to include for additional options if found (defaults touseroptions.mak). May be useful if you want to quickly switch betweendifferent build configurations.
Set to change the name of the subfolder used for project files, generatedsources, object files, and intermediate libraries (defaults to build).
Set to 1 to force project files to be regenerated.
Set to 1 to show full commands when using GNU make as the build tool.This option applies immediately without needing regenerate project files.
Set to 1 to skip the working tree scan and not attempt to embed a gitrevision description in the version string.
Set the C/Objective-C compiler command. (This sets the target C compilercommand when cross-compiling.)
Set the C++/Objective-C++ compiler command. (This sets the target C++compiler command when cross-compiling.)
Set the linker command. This is often not necessary or useful because the Cor C++ compiler command is used to invoke the linker. (This sets the targetlinker command when cross-compiling.)
Set the Python interpreter command. You need Python 2.7 or Python 3 to buildMAME.
Set to 1 to use separate host and target compilers and linkers, asrequired for cross-compilation. In this case, OVERRIDE_CC,OVERRIDE_CXX and OVERRIDE_LD set the target C compiler, C++ compilerand linker commands, while CC, CXX and LD set the host Ccompiler, C++ compiler and linker commands.
Set to 1 to build additional tools along with the emulator, includingunidasm, chdman, romcmp, and srcclean.
Set to 1 to disable building the PortAudio sound output module.
Set to 1 to include the Qt debugger on platforms where it’s not built bydefault (e.g. Windows or MacOS), or to 0 to disable it. You’ll need toinstall Qt development libraries and tools to build the Qt debugger. Theprocess depends on the platform.
Set to 1 to disable treating compiler warnings as errors. This may beneeded in marginally supported configurations.
Set to 0 to disable deprecation warnings (note that deprecation warningsare not treated as errors).
Set to 1 to enable runtime assertion checks and additional diagnostics.Note that this has a performance cost, and is most useful for developers.
Set optimisation level. The default is 3 to favour performance at theexpense of larger executable size. Set to 0 to disable optimisation (canmake debugging easier), 1 for basic optimisation that doesn’t have aspace/speed trade-off and doesn’t have a large impact on compile time, 2to enable most optimisation that improves performance and reduces size, ors to enable only optimisations that generally don’t increase executablesize. The exact set of supported values depends on your compiler.
Set to 1 to include additional debugging symbols over the default for thetarget platform (many target platforms include function name symbols bydefault).
Numeric value that controls the level of detail in debugging symbols. Highernumbers make debugging easier at the cost of increased build time andexecutable size. The supported values depend on your compiler. For GCC andsimilar compilers, 1 includes line number tables and external variables,2 also includes local variables, and 3 also includes macrodefinitions.
Additional command-line options to pass to the compiler and linker. This isuseful for supplying code generation or ABI options, for example to enablesupport for optional CPU features.
Additional command-line options to pass to the compiler when compiling Csource files.
Additional command-line options to pass to the compiler when compiling C++source files.
Additional command-line options to pass to the compiler when compilingObjective-C source files.
Additional command-line options to pass to the compiler when compilingObjective-C++ source files.
SDL installation root directory for shared library style SDL.
Search path for SDL framework.
Set to 1 to use shared library style SDL on targets where framework isdefault.
Set to 1 to prefer the system installation of the Asio C++ asynchronousI/O library over the version provided with the MAME source.
Set to 1 to prefer the system installation of the Expat XML parserlibrary over the version provided with the MAME source.
Set to 1 to prefer the system installation of the zlib data compressionlibrary over the version provided with the MAME source.
Set to 1 to prefer the system installation of the libjpeg imagecompression library over the version provided with the MAME source.
Set to 1 to prefer the system installation of the libFLAC audiocompression library over the version provided with the MAME source.
Set to 1 to prefer the system installation of the embedded Luainterpreter over the version provided with the MAME source.
Set to 1 to prefer the system installation of the SQLITE embeddeddatabase engine over the version provided with the MAME source.
Set to 1 to prefer the system installation of the PortMidi library overthe version provided with the MAME source.
Set to 1 to prefer the system installation of the PortAudio library overthe version provided with the MAME source.
Set to 1 to prefer the version of SDL provided with the MAME source overthe system installation. (This is enabled by default for Visual Studio andAndroid builds. For other configurations, the system installation of SDL ispreferred.)
Set to 1 to prefer the system installation of the Julia utf8proc libraryover the version provided with the MAME source.
Set to 1 to prefer the system installation of the GLM OpenGL Mathematicslibrary over the version provided with the MAME source.
Set to 1 to prefer the system installation of the Tencent RapidJSONlibrary over the version provided with the MAME source.
Set to 1 to prefer the system installation of the pugixml library overthe version provided with the MAME source.
GCC 7 for 32-bit x86 targets produces spurious out-of-bounds access warnings.Adding NOWERROR=1 to your build options works around this by not treatingwarnings as errors.
The GNU C Library has options to perform additional compile- and run-timechecks on string operations, enabled by defining the _FORTIFY_SOURCE
preprocessor macro. This is intended to improve security at the cost of asmall amount of overhead. MAME is not secure software, and we do notsupport building with _FORTIFY_SOURCE
defined.
Some Linux distributions (including Gentoo and Ubuntu) have patched GCC todefine _FORTIFY_SOURCE
to 1
as a built-in macro. This is problematicfor more projects than just MAME, as it makes it hard to disable the additionalchecks (e.g. if you don’t want the performance impact of the run-time checks),and it also makes it hard to define _FORTIFY_SOURCE
to 2
if you want toenable stricter checks. You should really take it up with the distributionmaintainers, and make it clear you don’t want non-standard GCC behaviour. Itwould be better if these distributions defined this macro by default in theirpackaging environments if they think it’s important, rather than trying to forceit on everything compiled on their distributions. (This is what Red Hat does:the _FORTIFY_SOURCE
macro is set in the RPM build environment, and not bydistributing a modified version of GCC.)
If you get compilation errors in bits/string_fortified.h
you should firstensure that the _FORTIY_SOURCE
macro is defined via the environment (e.g.a CFLAGS or CXXFLAGS environment variable). You can check to seewhether the _FORTIFY_SOURCE
macro is a built-in macro with your version ofGCC with a command like this:
gcc -dM -E - < /dev/null | grep _FORTIFY_SOURCE
If _FORTIFY_SOURCE
is defined to a non-zero value by default, you can workaround it by adding -U_FORTIFY_SOURCE to the compiler flags (e.g. by usingthe ARCHOPTS setting, or setting the CFLAGS and CXXFLAGS environmentvariables.
The LLVM linker is generally faster than the GNU linker that GCC uses bydefault. This is more pronounced on systems with a high overhead for filesystem operations (e.g. Microsoft Windows, or when compiling on a disk mountedover a network). To use the LLVM linker with GCC, ensure the LLVM linker isinstalled and add -fuse-ld=lld
to the linker options (e.g. in theLDFLAGS environment variable or in the ARCHOPTS setting).
Xcode Cannot Be Installed On Macintosh Hdr
MAME’s build system has basic support for cross-compilation. SetCROSS_BUILD=1 to enable separate host and target compilers, setOVERRIDE_CC and OVERRIDE_CXX to the target C/C++ compiler commands, andif necessary set CC and CXX to the host C/C++ compiler commands. If thetarget OS is different to the host OS, set it with TARGETOS. For example itmay be possible to build a MinGW32 x64 build on a Linux host using a commandlike this:
(The additional packages required for producing a standard MinGW32 x64 build ona Fedora Linux host are mingw64-gcc-c++
, mingw64-winpthreads-static
andtheir dependencies. Non-standard builds may require additional packages.)
MAME may be built using the LLVM project’s “libc++” C++ Standard Library. Theprerequisites are a working clang/LLVM installation, and the libc++ developmentlibraries. On Fedora Linux, the necessary packages are libcxx,libcxx-devel, libcxxabi and libcxxabi-devel. Set the C and C++compiler commands to use clang, and add -stdlib=libc++ to the C++ compilerand linker options. You could use a command like this:
Xcode Cannot Be Installed On Macintosh Hdmi
The options following the make command may be placed in a prefix makefile ifyou want to use this configuration regularly, but LDFLAGS needs to be be setin the environment.
GCC may be built and installed to a custom location, typically by supplying the--prefix= option to the configure command. This may be useful if youwant to build MAME on a Linux distribution that still uses a version of GNUlibstdC++ that predates C++17 support. To use an alternate GCC installation to,build MAME, set the C and C++ compilers to the full paths to the gcc andg++ commands, and add the library path to the run-time search path. If youinstalled GCC in /opt/local/gcc72, you might use a command like this:
You can add these options to a prefix makefile if you plan to use thisconfiguration regularly.