Skip to main content

How to run Windows programs on Android with Box86 + Wine in Termux Proot

Smartphone Termux Tutorial Box86 Box64 Wine Termux Raspberry Pi
Table of Contents

🇹🇼 中文版

We can run Windows programs (.exe) with Box86 and Wine in Termux proot on Android. No root required.

Wine is a translation layer for running x86/x64 Windows programs on Linux. However, most of Android devices run on ARM architecture so Wine will not work in ARM platform.

Fortunately, a new program named Box86 can transalte x86 instructions into ARM instructions. And there is Box64 for transalting x64 instrcutions.

Therefore, you can run x86 appplications on ARM devices! And Box86 is faster than QEMU emualtion.

By combining Box86 and Wine, now we could run Windows programs in Termux proot.

1. Install Termux Proot
#

Install proot Debian and setup Termux X11.

2. Install Box86 & Box64
#

  1. Log into proot Debian as normal user.
proot-distro login debian --user user shared-tmp
  1. Install Box86 from ryanfortner’s repo
wget https://ryanfortner.github.io/box86-debs/box86.list -O /etc/apt/sources.list.d/box86.list
wget -qO- https://ryanfortner.github.io/box86-debs/KEY.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/box86-debs-archive-keyring.gpg
dpkg --add-architecture armhf
sudo apt update
sudo apt install libc6:armhf
sudo apt install box86-android:armhf
  1. Install Box64 from ryanfortner’s repo
wget https://ryanfortner.github.io/box64-debs/box64.list -O /etc/apt/sources.list.d/box64.list
wget -qO- https://ryanfortner.github.io/box64-debs/KEY.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/box64-debs-archive-keyring.gpg
sudo apt update
sudo apt install box64-android

3. Install Wine and Wine64
#

Wine is for running x86 (32bit) programs;whereas Wine64 is for x64 programs.

Since we are on ARM64 platform, we cannot install pacakges (i386:wine) from foreign architecture while using APT. Here we will install Wine by downloading binaries and moving them to the proper path.

  1. Install dependecies of Wine
sudo apt install nano cabextract libfreetype6 libfreetype6:armhf libfontconfig libfontconfig:armhf libxext6 libxext6:armhf libxinerama-dev libxinerama-dev:armhf libxxf86vm1 libxxf86vm1:armhf libxrender1 libxrender1:armhf libxcomposite1 libxcomposite1:armhf libxrandr2 libxrandr2:armhf libxi6 libxi6:armhf libxcursor1 libxcursor1:armhf libvulkan-dev libvulkan-dev:armhf zenity
  1. Download Wine binaries from Kron4ek’s Wine-Builds. This archive contains Wine and Wine64
cd ~/
wget https://github.com/Kron4ek/Wine-Builds/releases/download/8.0.1/wine-8.0.1-amd64.tar.xz
wget https://github.com/Kron4ek/Wine-Builds/releases/download/8.0.1/wine-8.0.1-x86.tar.xz
  1. Extract the archive.
tar xvf wine-8.0.1-amd64.tar.xz
tar xvf wine-8.0.1-x86.tar.xz
rm wine-8.0.1-amd64.tar.xz wine-8.0.1-x86.tar.xz
mv wine-8.0.1-amd64 wine64
mv wine-8.0.1-x86 wine
  1. Create shortcuts
echo '#!/bin/bash
export WINEPREFIX=~/.wine32
box86 '"$HOME/wine/bin/wine "'"$@"' > /usr/local/bin/wine
chmod +x /usr/local/bin/wine
echo '#!/bin/bash
export WINEPREFIX=~/.wine64
box64 '"$HOME/wine64/bin/wine64 "'"$@"' > /usr/local/bin/wine64
chmod +x /usr/local/bin/wine64
  1. Add PATH of Wine to ~/.bashrc
echo 'export DISPLAY=:0
export BOX86_PATH=~/wine/bin/
export BOX86_LD_LIBRARY_PATH=~/wine/lib/wine/i386-unix/:/lib/i386-linux-gnu/:/lib/aarch64-linux-gnu/:/lib/arm-linux-gnueabihf/:/usr/lib/aarch64-linux-gnu/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/i386-linux-gnu/
export BOX64_PATH=~/wine64/bin/
export BOX64_LD_LIBRARY_PATH=~/wine64/lib/i386-unix/:~/wine64/lib/wine/x86_64-unix/:/lib/i386-linux-gnu/:/lib/x86_64-linux-gnu:/lib/aarch64-linux-gnu/:/lib/arm-linux-gnueabihf/:/usr/lib/aarch64-linux-gnu/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/i386-linux-gnu/:/usr/lib/x86_64-linux-gnu' >> ~/.bashrc

source ~/.bashrc
  1. Finally, install winetricks
cd ~/
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
mv winetricks /usr/local/bin/
echo '#!/bin/bash
export BOX86_NOBANNER=1 WINE=wine WINEPREFIX=~/.wine32 WINESERVER=~/wine/bin/wineserver
wine '"/usr/local/bin/winetricks "'"$@"' > /usr/local/bin/winetricks32
chmod +x /usr/local/bin/winetricks32
echo '#!/bin/bash
export BOX64_NOBANNER=1 WINE=wine64 WINEPREFIX=~/.wine64 WINESERVER=~/wine64/bin/wineserver
wine64 '"/usr/local/bin/winetricks "'"$@"' > /usr/local/bin/winetricks64
chmod +x /usr/local/bin/winetricks64
  1. Create a shortcut of Wine’s file explorer on Desktop so you could start exe in it.
cd ~/Desktop
echo '[Desktop Entry]
Name=Wine32 Explorer
Exec=bash -c "wine explorer"
Icon=wine
Type=Application' > ~/Desktop/Wine32_Explorer.desktop
chmod +x ~/Desktop/Wine32_Explorer.desktop
cp ~/Desktop/Wine32_Explorer.desktop /usr/share/applications/

cd ~/Desktop
echo '[Desktop Entry]
Name=Wine64 Explorer
Exec=bash -c "wine64 explorer"
Icon=wine
Type=Application' > ~/Desktop/Wine64_Explorer.desktop
chmod +x ~/Desktop/Wine64_Explorer.desktop
cp ~/Desktop/Wine64_Explorer.desktop /usr/share/applications/

4. Install DXVK
#

DXVK is a Vulkan-based translation layer for Direct3D 9/10/11. This may improve performance of some Windows games.

  1. Install Box86 & Wine

  2. Install DXVK

sudo apt install mesa-vulkan-drivers mesa-vulkan-drivers:armhf libvulkan1 libvulkan1:armhf
wget https://github.com/doitsujin/dxvk/releases/download/v2.1/dxvk-2.1.tar.gz
tar xvf dxvk-2.1.tar.gz
cd dxvk-2.1
cp x32/* ~/.wine32/drive_c/windows/system32
cp x32/* ~/.wine64/drive_c/windows/system32
cp x64/* ~/.wine64/drive_c/windows/syswow64
  1. Open winecfg and manually add DLL overrides for d3d11, d3d10core, dxgi, and d3d9.
wine winecfg
wine64 winecfg

5. Run exe with Box86 + Wine
#

You could check the comapbility of specific programs on Wine Application Database and install the packages through winetricks.

Some programs may need GPU Acceleration to work.


Make sure to check your programs are 32bit or 64bit before running them.

For example, to run Notepad++ 32bit, open terminal at the directory where the exe is, and run:

box86 wine notepad++.exe

Wait for few seconds, then the window of Notepad++ will pop out.

If the program is 64 bit, run with Box64 instead:

box64 wine64 notepad++.exe

You could use WINEPREFIX to create a separate directory (the fake “C drive” created by Wine) for running specific programs:

export WINEPREFIX=~/.wine64
export WINEARCH=win64
box64 wine64 notepad++.exe

References
#

Related

virglrenderer: Termux GPU hardware acceleration tutorial
Smartphone Termux Tutorial Wine Termux
How to play Minecraft Java Edition on Android using Termux proot
Smartphone Termux Tutorial Raspberry Pi Minecraft Termux
[Root] Install Ubuntu in chroot on Android without Linux Deploy
Smartphone Termux Tutorial Linux Android Ubuntu Termux

Leave a comment

Choose the comment system you like. Giscus for codes, Disqus for anonymous comments.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see forcing Disqus ADs on this page. Sometimes your comment may need to be reviewed, resulting in delayed display. Thank you for your understanding.