Setting up Wine for effect compilation
Learn how to set up Wine on macOS and Linux so that MonoGame can compile effects (shaders).
Effect (shader) compilation requires access to DirectX. This means it will not work natively on macOS and Linux systems, but it can be used through Wine.
MonoGame provides a setup script that sets up the Wine environment for effect compilation. The MonoGame Effects Compiler (MGFXC) then uses that environment to compile your effects.
Note
You do not need Wine on Windows. On macOS and Linux, you only need it if your game uses its own effects.
Set up Wine
Follow the steps for your operating system.
Install Homebrew
Open a terminal window and enter the following commands:
brew install wget p7zip curl brew install --cask xquartz curl -L -o wine.tar.xz "https://github.com/Gcenx/macOS_Wine_builds/releases/download/11.0_1/wine-stable-11.0_1-osx64.tar.xz" tar -xJf wine.tar.xz sudo mv "Wine Stable.app" /Applications/ sudo xattr -dr com.apple.quarantine "/Applications/Wine Stable.app" echo "export PATH="/Applications/Wine Stable.app/Contents/Resources/wine/bin:$PATH"" >> ~/.zprofile source ~/.zprofile wine --versionNow that the prerequisites are installed, download the mgfxc_wine_setup.sh script and execute it by entering the following command in the terminal:
wget -qO- https://monogame.net/downloads/net9_mgfxc_wine_setup.sh | bash
This will create a new directory called .winemonogame in your home directory. If you ever wish to undo the setup this script performed, delete that directory.
Note
For the time being, MonoGame requires that you install the Intel version even if you are using an Apple Silicon (M1/M2) Mac. For Apple Silicon Macs, it also requires that Rosetta be enabled.
Troubleshooting
Issue: "wine64 not found" error on Arch Linux
If the setup script fails with wine64 not found, ensure you created the symlink from step 2 of the Arch Linux instructions:
sudo ln -s /usr/bin/wine /usr/local/bin/wine64
Issue: Shader compilation fails with "MGFXC effect compiler requires a valid Wine installation"
This means the MGFXC_WINE_PATH environment variable is not set. On Arch Linux, ensure you:
- Added it to
/etc/environmentas shown in step 4 of the Arch Linux instructions. - Logged out and logged back in.
- Can see it with
echo $MGFXC_WINE_PATH.
Issue: Wine creates a .wine-mgfxc directory instead of using .winemonogame
This is another symptom of the environment variable not being set. Follow the steps in the previous issue to resolve it.
Issue: Wine version too old
The MonoGame setup script requires Wine 8.0 or later. Check your version:
wine --version
If it is too old on Arch Linux, update your system:
sudo pacman -Syu
Issue: Rider cannot compile effects on Linux
You might need to add the MGFXC_WINE_PATH environment variable to /etc/environment for Rider to pick it up. See Rider cannot see all Environmental Variables for details.