Skip to main content

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

Categories   Smartphone Termux Tutorial
Tags   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. Enable armhf support
dpkg --add-architecture armhf
  1. Add ryanfortner’s repo and install Box86
sudo 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 | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/box86-debs-archive-keyring.gpg

sudo apt update

sudo apt install box86-android:armhf
  1. Add ryanfortner’s repo and install Box64
sudo 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 | sudo 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 Wine’s dependencies
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 and Wine64 from Kron4ek’s Wine-Builds. The latest version is Wine 9.7.

cd ~/

wget https://github.com/Kron4ek/Wine-Builds/releases/download/9.7/wine-9.7-amd64.tar.xz

wget https://github.com/Kron4ek/Wine-Builds/releases/download/9.7/wine-9.7-x86.tar.xz
  1. Unzip the file and delete redundant files
tar xvf wine-9.7-amd64.tar.xz

tar xvf wine-9.7-x86.tar.xz

rm wine-9.7-amd64.tar.xz wine-9.7-x86.tar.xz

mv wine-9.7-amd64 wine64

mv wine-9.7-x86 wine
  1. Create a symbolic link and point /usr/local/bin/wine to $HOME/wine/bin/wine.
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 the PATH of Box86 and Box64 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. 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 to the Wine file manager on the Linux desktop, so that you can directly click the exe to start:
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 dependencies
sudo apt install mesa-vulkan-drivers mesa-vulkan-drivers:armhf libvulkan1 libvulkan1:armhf
  1. Download the latest version of DXVK from Github. The latest version is 2.3.1
wget https://github.com/doitsujin/dxvk/releases/download/v2.3.1/dxvk-2.3.1.tar.gz
  1. Unzip and move the dxvk files to the Wine directory
tar xvf dxvk-2.3.1.tar.gz

cddxvk-2.3.1
cp x32/* ~/.wine32/drive_c/windows/system32
cp x32/* ~/.wine64/drive_c/windows/system32
cp x64/* ~/.wine64/drive_c/windows/syswow64
  1. Open Wine settings, switch to the library tab, and overwrite the DLL files of 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
Categories   Smartphone Termux Tutorial
Tags   Wine Termux
How to play Minecraft Java Edition on Android using Termux proot
Categories   Smartphone Termux Tutorial
Tags   Raspberry Pi Minecraft Termux
How to use Termux X11 - The X server on Android phone
Categories   Smartphone Termux Tutorial
Tags   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.