How do I run MMD on Linux? Does MikuMikuDance run on Linux? How do I run MMD using Wine on Linux? Can I use MME on Linux? How do I use DXVK with MMD? How do I run MMD on Ubuntu?
How to run MikuMikuDance in Linux using Wine and DXVK
Hey everyone, it is parkeerwacht here! It has been a while since I have written for the pages here at LearnMMD! But I am back with a special tutorial. How to run MMD in Linux! And “no”, not some alternate version of MMD: run the full 64-bit Windows version (9.32 as of this writing) including MME!
Ok, so a little story before we begin: Since I have always been interested in the technical aspect of MMD, and also computers in general, I like challenges! So I switched to Linux as my main operating system about a year ago, as of writing this. I have a problem however: I can no longer use MMD! MikuMikuDance only runs on Windows. Because I can play my Windows games using DirectX just fine, using Wine and DXVK, I thought could I do the same for MMD? And the answer is YES!
For this tutorial, I searched the internet and found multiple sources (I will cite these)… I combined them into this one guide for MMD specifically. Also I found a script on a Japanese website. I looked into its code and I did some testing. I wrote my own script based of that one. I also found a resource to do it manually. The script only automates things. ANYWAY enough rambling about… LET’S GET STARTED!!!
Also lets put some credit to the people who helped me with the information:
Without them I would not have been able to write this.
Now a little thing before we begin, I need to start with a disclaimer:
We are going to mess around with the Linux terminal. Make sure you know what you are doing! All the scripts I listed are provided “as is”. If for some reason they do not work, try to troubleshoot them yourself. This is due to the constant updates to wine, winetricks and DXVK. If it is completely broken let me know and I will update them. Use this tutorial and the scripts at your own risk. This guide only works for MMD+MME. It is not compatible with PMXe!
ALSO NOTE: IF YOU ARE SENSITIVE TO FLASHING IMAGES DO NOT USE MMD IN LINUX. FLASHING ARTIFACTS MAY OCCUR!!!
The following instructions are written for Ubuntu (and derived distro’s) IF you run something else follow the instructions for your distro instead. For my install script, I listed all the commands so you can follow them for your distro.
First of all check if your system is compatible with the requirements for MMD, Vulkan and DXVK
- 64-bit System.
- Operating system: Ubuntu 18.04 or newer, I recommend 20.04
(Note: Other Linux distro’s will probably work fine if they are debian based. However I have done my testing on Ubuntu 20.04)
- an AMD or Nvidia Graphics card that supports Vulkan. (here is a list of supported cards: https://en.wikipedia.org/wiki/Vulkan_(API)#Compatibility )
- Recommended: at least 2 monitors (I will explain why later)
- Knowledge of the Linux terminal
Here is a screenshot of my install:
Step 1 Setting up Vulkan.
Note: If you already got all the drivers and software installed to run Vulkan applications on your system you can skip this step.
What is Vulkan?
Vulkan is a graphical computing API much like DirectX and OpenGL etc. (very simplified) Now since Linux does not support DirectX, we need to find another way. Vulkan has less latency than OpenGL, and is generally more efficient. It is also compatible across multiple platforms.
1. Installing Drivers
Before we can use Vulkan we need to install some drivers first. PLEASE FOLLOW INSTRUCTIONS CAREFULLY!!!!!!!
DO NOT FORGET THE FOLLOWING COMMAND:
We need to set up the system so it accepts x86 packages. Do this via:
sudo dpkg --add-architecture i386
For AMD cards
Make sure you are running either AMDVLK or AMDGPU-pro (DO NOT INSTALL BOTH)
I recommend using AMDVLK. I had the best experiences with this driver. The AMDGPU-pro package from AMD tends to break some games/applications using Vulkan. I have not tested AMDGPU-pro drivers , only AMDVLK.
Follow the instructions on this page under install with pre-build driver:
For Nvidia cards
see instructions below for installing Vulkan dependencies
2. Installing Vulkan dependencies
To install Vulkan on your system I highly suggest following the steps on this page for your version of Ubuntu (or other distro) and GPU.
here is the link: https://github.com/lutris/docs/blob/master/InstallingDrivers.md
Step 2 Installing Wine
NOTE: If you already have the latest wine-staging version on your system you can skip this step.
What is Wine?
Wine stands for Wine Is Not an Emulator. It is a compatibility layer that is able to run Windows programs on other operating systems, like Linux and macOS. This has a huge performance boost compared to running a virtual machine. It translates all the Windows API calls on the fly so Linux can understand these. This saves a lot of memory usage and performance hits. Plus you can integrate Windows applications in your desktop environment [source]
We need this program so we can run Windows programs on Linux. MMD is a Windows only program.
We need to install Wine-staging (latest version) to be able to run MMD with DXVK.
Note: If you already got the latest version of wine-staging installed, you can skip this step. If you have a different variant of Wine installed, uninstall it and reinstall with wine-staging
MAKE SURE TO INSTALL THE STAGING BRANCH!!
Before you setup anything, run this command if you haven’t done so already:
sudo dpg --add-architecture i386
ONLY FOR UBUNTU 18.04 USERS!!! IF YOU HAVE 19.10 OR NEWER SKIP TOWARDS SETTING UP WINE.
You need to set up FAudio first. This package is not in Ubuntu’s package manager but it is a dependency for Wine. To install follow these commands:
wget https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/i386/libfaudio0_19.07-0~bionic_i386.deb wget https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/amd64/libfaudio0_19.07-0~bionic_amd64.deb sudo dpkg -i libfaudio0_19.07-0~bionic_*.deb
If you get an error saying missing dependencies, enter the following command:
sudo apt -f install
Now go to the next part
Setting up wine
Follow the instructions on this page:
MAKE SURE TO INSTALL WINE-STAGING!!!!
Now you have Wine installed
You can test it by typing the following command
Step 3 Setting up Japanese locale.
We need to set up Japanese locale on the system to make sure MMD runs properly. This also allows you to unzip your models and such (due to them being zipped in the Japanese language format). We need to install the Japanese language pack for this
To install this you enter the following command.
sudo apt install language-pack-ja
For all your models, accessories, effects, motion data etc. you need to use this script to unpack it.
This will preserve all the original Japanese filenames etc. and this is important for your models and effects, for example.
Most archive formats are supported!
Dependencies for the script:
p7zip-full p7zip-rar convmv
to install them run this command:
sudo apt install p7zip-full p7zip-rar convmv
once these are installed you go to your MMD folder in a terminal and run the following commands:
wget https://secureservercdn.net/18.104.22.168/8b1.175.myftpupload.com/wp-content/uploads/2020/12/linux-unzip-tool.tar.gz tar -xf linux-unzip-tool.tar.gz chmod +x Decompress-as-Japanese.sh
instructions on how to use will appear on screen once you run it.
Run the file using:
Step 4 Setting up Winetricks
NOTE: EVEN IF YOU HAVE WINETRICKS INSTALLED FOLLOW THE STEPS BELOW.
To use Winetricks we need to set up a few dependencies first.
These packages are aria2 binutils, cabextract, fuseiso, p7zip-full, policykit-1, unrar, unzip, xdg-utils, xz-utils and zenity
install them with the following:
sudo apt install aria2 binutils cabextract fuseiso p7zip-full policykit-1 unrar unzip xdg-utils xz-utils zenity
My autoinstall script will setup winetricks for us. (unless you manually install)
For manual install please download the correct version here: https://github.com/Winetricks/winetricks/releases/tag/20201206
extract winetricks from the src directory to your home directory.
Step 5 setting up MMD
Now we get to the MMD side of things.
For MMD we are gonna set up a special wineprefix named WineMMD64, this will be a hidden folder in the home directory.
I have found a script online that does everything that is needed for MMD to run automatically. (credit to Ginga8) This one is slightly outdated with the latest winetricks and ubuntu builds. I have modified it to work with the latest winetricks and setup DXVK for us.
Automatic install (Reccomended)
Download and extract my scripts using the following commands.
CD <Path to your MMD folder> wget https://secureservercdn.net/22.214.171.124/8b1.175.myftpupload.com/wp-content/uploads/2020/12/WineMMD64.tar.gz tar -xf WineMMD64.tar.gz chmod +x WineMMD64Setup
Now you can run it using the following command:
This might take a while depending on your internet speed.
If the installation fails you can delete the folders .WineMMD64 and mmdtemp in your home directory. and try again. (if you cannot see it, press ctrl+h to reveal hidden folders)
Sometimes Winetricks will fail downloading one of the required libraries. (you can try deleting the winetricks folder in /home/<username>/.cache this will have winetricks re-download all the files)
If the installation fails again, try to look for errors and search them online or ask in the comments below.
Alternatively you can do it all manually by entering the following commands: (Make sure the correct version of Winetricks is in your home directory)
#setup wineprefix and set it up for MMD WINEPREFIX=~/.WineMMD64 wineboot WINEPREFIX=~/.WineMMD64 ./winetricks -q vcrun2005 vcrun2008 vcrun2010 d3dxof d3dx9_43 fakejapanese_ipamona vcrun2013 devenum quartz qcap qedit WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v msvcr90 /t reg_sz /d "builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v d3d9 /t reg_sz /d "native,builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v d3dx9_43 /t reg_sz /d "native,builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v d3dxof /t reg_sz /d "native,builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v devenum /t reg_sz /d "builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v quartz /t reg_sz /d "native,builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v qcap /t reg_sz /d "native,builtin" WINEPREFIX=~/.WineMMD64 wine reg add HKCU\\Software\\Wine\\DllOverrides /v qedit /t reg_sz /d "native,builtin" WINEPREFIX=~/.WineMMD64 ./winetricks -q d3dcompiler_43 WINEPREFIX=~/.WineMMD64 ./winetricks -q directshow gdiplus win7 #setting up DXVK v1.7.3 wget -nc https://github.com/doitsujin/dxvk/releases/download/v1.7.3/dxvk-1.7.3.tar.gz tar xf dxvk-1.7.3.tar.gz cd dxvk-1.7.3/ export WINEPREFIX=~/.WineMMD64 chmod +x setup_dxvk.sh ./setup_dxvk.sh install export WINEPREFIX=~/.wine cd .. rm -r -v dxvk-1.7.3/ rm -v dxvk-1.7.3.tar.gz
Step 6 download and set up MMD + MME
Once you have done the last step, we can finally download and set up MMD
- Use the unzip tool from earlier to unzip both archives. (this is to preserve the Japanese characters)
- put MMD into a folder of choice.
- Install MME as normal by putting the 3 DLL files in the same folder as MikuMikuDance.exe
- Put the MikuMikuDance file included in the archive downloaded before in the same folder as MikuMikuDance.exe
- Make it executable with the following command:
chmod +x MikuMikuDance
Step 7 Launching MMD and doing final fixes
Now that everything is set up to go, get ready to run it for the first time!
If you got the script from the last step you can run it from the terminal.
Go to your MMD folder in a terminal window and run:
Alternatively you can start MMD with:
LANG=ja_JP.UTF-8 WINEPREFIX=~/.WineMMD64 wine MikuMikuDance.exe
Once you are in MMD you will see a garbled mess. This is an issue that is not on MMD’s end, it has to do with how Wine renders the window (I think)
If you get the following message:
This means MME could not start due to an error. Now this can mean many things.
When this happens MMD will crash afterwards.
I experienced this error for a while, these are some things to look for to fix this:
- Check if you got the proper GPU drivers installed.
- Check if your GPU Supports Vulkan/DXVK
- Delete the folder: ~/.WineMMD64 and the contents of the folder ~/.cache/winetricks/ Then run the script again.
- Try to install without DXVK, to do that hit CRTL-C when the script asks to press enter to install DXVK. Then delete the folder ~/mmdtemp.
- This can also be a problem on Wine’s end. To fix try the above to install without DXVK. This usually happens after Wine updates. Please let me know in the comments if this happens!
Now here is where the multi monitor setup I mentioned at the start comes in handy.
To fix the issues we have do the following:
- Go to the VIEW dropdown menu, select SEPARATE WINDOW. This will put your render window and controls on different windows. If you’ve got 2 monitors you can split them over 2 like I do.
- Open up the MME Effect mapping window, select the tool dropdown and click “Skip Device Validation” this is for compatibility issues with some effects. (Credit to petite philosophie)
- When it says MikuMikuDance.exe is not responding when loading files. Just let it wait, this may take a bit depending on what you are loading.
Here are some images: (Click on the images for the full size)
Here is how it looks on my system:
(Click image for full-size)
SO! here you go! Now you can run MikuMikuDance on Linux! Using Wine and DXVK we were able to set everything up.
My scripts will set up a special Wineprefix with all the required libraries installed. Have fun with MMD!
Known issues and notes
Nothing is perfect. What we are doing here is using a workaround, with several compatibility layers to run a Windows program on Linux. Like you have already seen, the render window of MMD is broken. You have to use separate screen to make it work. It is purely visual.
Some MME effects don’t like DXVK either. Although using DXVK has been able to make many effects like Raycast run much smoother. Yes Ray-MMD does run using this method. I haven’t tested many effects but most should run.
If you run into issues and you want to reinstall, Rename .WineMMD64 in your home directory to something else and re-run the script.
This guide does not work for PMXe! it required different libries setup
I want to know what does and doesn’t run, when it comes to models and effects. Put your experiences in the comments.
– SEE BELOW for MORE MMD TUTORIALS…