This document describes how to build libopenmpt and the JNI wrapper for macOS desktop (JVM) platform.
Before building, ensure you have the following installed:
- Xcode - Install from the Mac App Store
- Xcode Command Line Tools - Install via:
xcode-select --install
- CMake 3.21+ - Install via Homebrew:
brew install cmake
- JDK 11+ - Required for JNI headers. Recommended: JDK 17 or 21
- Download from Adoptium or install via Homebrew:
brew install openjdk@21
This builds libopenmpt without MP3, OGG, or Vorbis support. All native tracker formats (MOD, XM, IT, S3M, etc.) work perfectly.
cd libopenmpt/src/main/cpp/macos
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j8The built library will be at: libopenmpt/src/main/cpp/macos/build/lib/libopenmpt.dylib
mkdir -p shared/src/desktopMain/resources/native/macos-arm64
cp libopenmpt/src/main/cpp/macos/build/lib/libopenmpt.dylib shared/src/desktopMain/resources/native/macos-arm64/For Intel Macs, use macos-x64 instead of macos-arm64.
cd shared/src/desktopMain/cpp
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DLIBOPENMPT_INCLUDE_DIR=$(pwd)/../../../../libopenmpt/src/main/cpp \
-DLIBOPENMPT_LIBRARY=$(pwd)/../../resources/native/macos-arm64/libopenmpt.dylib
cmake --build . --config ReleaseThe JNI wrapper will be automatically placed in shared/src/desktopMain/resources/native/macos-arm64/.
For MP3, OGG, and Vorbis support, you need to download and build external dependencies.
cd libopenmpt/src/main/cpp
./build/download_externals.shThis downloads:
- mpg123 (MP3 support)
- libogg (OGG container support)
- libvorbis (Vorbis audio support)
cd libopenmpt/src/main/cpp/build/xcode-macosx
xcodebuild -workspace libopenmpt.xcworkspace -scheme libopenmpt -configuration Release -arch arm64For Intel Macs, use -arch x86_64.
For Universal Binary (both architectures):
xcodebuild -workspace libopenmpt.xcworkspace -scheme libopenmpt -configuration Release -arch arm64 -arch x86_64The built library will be in the Xcode DerivedData directory.
| Architecture | Directory Name | Description |
|---|---|---|
| Apple Silicon (M1/M2/M3) | macos-arm64 |
ARM64 architecture |
| Intel | macos-x64 |
x86_64 architecture |
For convenience, you can use the provided build script:
cd shared/src/desktopMain/cpp
./build_native.shThis script will:
- Detect your platform (macos-arm64 or macos-x64)
- Build the JNI wrapper
- Place the output in the correct resources directory
Ensure JAVA_HOME is set correctly:
export JAVA_HOME=$(/usr/libexec/java_home)Or specify it when running cmake:
cmake .. -DJAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/HomeEnsure the LIBOPENMPT_INCLUDE_DIR path is correct and points to the libopenmpt source directory.
- Check that both
.dylibfiles are in the resources directory - Verify architectures match:
file libopenmpt.dylibshould showarm64for Apple Silicon orx86_64for Intel - Check library dependencies:
otool -L libmodplayer_desktop.dylib
If building with external dependencies, ensure all dependencies (mpg123, ogg, vorbis) are built before libopenmpt.
After building, your resources directory should look like:
shared/src/desktopMain/resources/native/
├── linux-x64/
│ ├── libmodplayer_desktop.so
│ └── libopenmpt.so
├── macos-arm64/
│ ├── libmodplayer_desktop.dylib
│ └── libopenmpt.dylib
├── macos-x64/ # (if built for Intel)
│ ├── libmodplayer_desktop.dylib
│ └── libopenmpt.dylib
└── windows-x64/
├── modplayer_desktop.dll
└── openmpt.dll
After building the native libraries:
./gradlew :app:desktopRun