Installing DeSmuME from source on Linux
Contents |
Supported compilers
On the Linux platform, only the GCC compiler is supported.
Pre-requisites
The Linux version of DeSmuME comes in source code form only, and if your distribution does not package it or is packaging an old version you will have to compile the sources yourself. In order to compile DeSmuME from a source tarball, you will need to use one of the provided build systems.
Build System | Packages | Description |
---|---|---|
Code::Blocks | codeblocks | Can build all Linux ports. Has build targets for x86-64 and AArch64. |
Autotools | automake | Can build the GTK2 and CLI ports. |
Meson | meson | Can build the GTK and CLI ports. |
All DeSmuME builds require these packages:
gcc make gettext intltool libsdl2-dev libpcap-dev
Depending on the desired feature set, you will also need these optional packages:
Package | Description |
---|---|
libgtk2.0-dev | Required for the GTK2 frontend. |
libgtk-3-dev | Required for the GTK frontend. |
libglib2.0-dev | Required for the command-line only interface (CLI) frontend. |
libsoundtouch-dev | Required for the "P" audio synchronization method. |
libagg-dev | Required for the HUD feature. |
libopenal-dev | Required for NDS microphone input using OpenAL. |
libgl-dev | Required for the standard OpenGL 3D renderer. |
libgles-dev | Required for the OpenGL ES 3D renderer. |
libglx-dev | Required to run a standard OpenGL 3D renderer through a GLX context. |
libosmesa6-dev | Required to run a standard OpenGL 3D renderer through an OSMesa context. Note that this feature is deprecated. |
libegl-dev | Required to run a standard OpenGL or OpenGL ES 3D renderer through an EGL context. |
On Debian, you can have all the required and optional packages installed with this command:
sudo apt-get install build-essential gettext intltool libsdl2-dev libpcap-dev libgtk2.0-dev libgtk-3-dev libsoundtouch-dev libagg-dev libopenal-dev libgl-dev libgles-dev libglx-dev libegl-dev
Retrieve the DeSmuME Source Code
You can grab the latest source from:
https://github.com/TASEmulators/desmume/archive/refs/heads/master.zip
But usually, the best way to retrieve the latest source is to use the git clone command:
git clone http://github.com/TASEmulators/desmume.git desmume-master
If you would like to retrieve the latest stable release (v0.9.13 as of this writing), then use this command:
wget -O - https://github.com/TASEmulators/desmume/archive/refs/tags/release_0_9_13.tar.gz | tar xvz
Configure Options
These options will add or change the features available in the build.
Autotools | Meson | Description |
---|---|---|
--enable-opengl | -Dopengl | Adds the 3D renderer for standard OpenGL. |
--enable-opengles | -Dopengles | Adds the 3D renderer for OpenGL ES. Overrides --enable-opengl/-Dopengl. |
--enable-glx | -Dglx | The OpenGL 3D renderer will use a GLX context. Only works with standard OpenGL, and is incompatible with OpenGL ES. |
--enable-osmesa | -Dosmesa | The OpenGL 3D renderer will use an OSMesa context. Only works with standard OpenGL, and is incompatible with OpenGL ES. Overrides --enable-glx/-Dglx. Note that this feature is deprecated. |
--enable-egl | -Degl | The OpenGL 3D renderer will use an EGL context. Works with both standard OpenGL and OpenGL ES. Overrides --enable-glx/-Dglx and --enable-osmesa/-Dosmesa. |
--enable-hud | N/A (automatically handled) | Adds the HUD feature. |
--enable-openal | -Dopenal | Adds NDS microphone input using OpenAL. |
--enable-wifi | -Dwifi | Enables experimental Wi-Fi support. |
--enable-gdb-stub | -Dgdb-stub | Enables the GDB stub debugging features. |
Compiler Options
If you want to optimize the build on Linux, you should set the C++ compiler options to enable specific optimization for your processor.
You can do this by setting the CFLAGS
, CXXFLAGS
, and LDFLAGS
variables like shown below:
CFLAGS='-march=native -O2' CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS
Most end-users will want a fully optimized build. Modern GCC uses the following options:
CFLAGS='-march=native -Ofast -flto'
For more optimization options, see Optimization#Linux
Build Configuration Examples
Use some of these build configurations as a starting point for creating your own executables.
Fully Optimized and Fully Featured Build For Desktop PCs
Creates a build that includes all the features that DeSmuME for desktop Linux has to offer, with the highest performance possible. This is the most common build configuration for end-users.
Code::Blocks
Open the "desmume.cbp" project file, and then select one of the "x64_Release" build targets.
Autotools
CFLAGS='-march=native -Ofast -flto' CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS ./configure --enable-opengl --enable-hud --enable-openal
Meson
CFLAGS='-march=native -Ofast -flto' CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS meson setup -Dopengl=true -Dopenal=true mesonbuild
Fully Optimized and Fully Featured Build For ARM Devices
Creates a build that includes all the features that DeSmuME for Linux has to offer when running on ARM-based devices, with the highest performance possible.
Code::Blocks
Open the "desmume.cbp" project file, and then select one of the "AArch64_Release" build targets.
Autotools
CFLAGS='-march=native -Ofast -flto' CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS ./configure --enable-opengles --enable-egl --enable-hud --enable-openal
Meson
CFLAGS='-march=native -Ofast -flto' CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS meson setup -Dopengles=true -Degl=true -Dopenal=true mesonbuild
Build Instructions
First, enter the POSIX frontend directory:
cd desmume/src/frontend/posix/
Next, choose one of the three supported build systems, Autotools, Meson, or the Code::Blocks project, and then perform the following steps to make your own DeSmuME build.
Code::Blocks
1. Open the "codeblocks/desmume.cbp" project file. 2. Choose the menu option "Build > Select target", and then select one of the build targets. 3. Choose the menu option "Build > Build".
Autotools
./autogen.sh <COMPILER_OPTIONS> ./configure <CONFIGURE_OPTIONS> make sudo make install
Meson
<COMPILER_OPTIONS> meson setup <CONFIGURE_OPTIONS> mesonbuild meson compile -C mesonbuild
Build Executables
After the build completes, you can find the DeSmuME build executables located according to the following chart.
Frontend | Code::Blocks Executable | Autotools Executable | Meson Executable |
---|---|---|---|
GTK2 | codeblocks/bin/GTK2_Release/DeSmuME_* | gtk2/desmume | N/A |
GTK | codeblocks/bin/GTK3_Release/DeSmuME_* | N/A | mesonbuild/gtk/desmume |
CLI | codeblocks/bin/CLI_Release/desmume-cli-* | cli/desmume-cli | mesonbuild/cli/desmume-cli |
Known issues
- If you have a crash on a 64bit environment while disabling/enabling sound during gameplay, deinstall agg (libagg-dev on Debian) and rebuild. This should solve the problem. (Alvin: Is this still applicable?)
- Some people on MacOS X have a broken build environment, mixing pieces from fink / macports / source installation / etc... That is wrong and painful for both the user and the developers who have to sort out build issues. Please don't do that! To workaround the issue you can try passing the needed include paths to autoreconf. Modify autogen.sh adding -B/my/path/ to autoreconf invocation, the path should be -B/sw for fink and -B/opt/local for macports. After the modify rerun ./autogen.sh and ./configure.