🇺🇸 English version
如果想在Android手機跑Windows exe程式,在Termux中用Box86/Box64轉譯x86架構的Wine,再用來跑Windows程式會是個好方法。

我們知道Linux平台有Wine這個軟體能跑Windows程式和遊戲,且幾乎沒有效能損失。但是Wine只能轉譯x86/x64架構的Windows程式,在以ARM架構為主的Android裝置無法直接使用。
所以我們需要一個轉譯器,那就是Box86和Box64。Box86用於轉譯32位元的x86指令集為ARM;Box64則是將64位元的x64指令集轉為ARM64,二者可以共存。
相較於Exagear,Box86是開源免費的技術,並且Github每週都有更新,作者正在積極完善各類功能。
首先,安裝Termux,再安裝Proot Debain。
用Termux X11存取桌面環境。
以一般帳戶登入Proot Debian,啟動桌面環境。
- 啟用armhf儲存庫,安裝編譯的前置依賴套件
1
2
3
4
5
6
7
8
9
| sudo apt update && sudo apt upgrade -y
sudo apt install git build-essential cmake wget -y
sudo dpkg --add-architecture armhf
sudo apt update && sudo apt upgrade -y
sudo apt install gpg -y
sudo apt install libgl1:armhf libgl1 -y
sudo apt install libasound2:armhf libc6:armhf libglib2.0-0:armhf libgphoto2-6:armhf libgphoto2-port12:armhf libgstreamer-plugins-base1.0-0:armhf libgstreamer1.0-0:armhf libpcap0.8:armhf libpulse0:armhf libsane1:armhf libudev1:armhf libusb-1.0-0:armhf libx11-6:armhf libxext6:armhf ocl-icd-libopencl1:armhf libasound2-plugins:armhf libncurses6:armhf libcap2-bin:armhf libcups2:armhf libdbus-1-3:armhf libfontconfig1:armhf libfreetype6:armhf libglu1-mesa:armhf libgnutls30:armhf libgssapi-krb5-2:armhf libkrb5-3:armhf libodbc1:armhf libosmesa6:armhf libsdl2-2.0-0:armhf libv4l-0:armhf libxcomposite1:armhf libxcursor1:armhf libxfixes3:armhf libxi6:armhf libxinerama1:armhf libxrandr2:armhf libxrender1:armhf libxxf86vm1:armhf -y
sudo apt install libasound2 libc6 libglib2.0-0 libgphoto2-6 libgphoto2-port12 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libpcap0.8 libpulse0 libsane1 libudev1 libunwind8 libusb-1.0-0 libx11-6 libxext6 ocl-icd-libopencl1 libasound2-plugins libncurses6 libcap2-bin libcups2 libdbus-1-3 libfontconfig1 libfreetype6 libglu1-mesa libgnutls30 libgssapi-krb5-2 libkrb5-3 libodbc1 libosmesa6 libsdl2-2.0-0 libv4l-0 libxcomposite1 libxcursor1 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxxf86vm1 -y
sudo apt clean && sudo apt autoremove
|
- 使用樹莓派參數編譯Box86,大概需要5分鐘。
1
2
3
4
5
6
7
8
9
| cd ~/
sudo apt-get install libc6:armhf
sudo apt install gcc-arm-linux-gnueabihf
git clone https://github.com/ptitSeb/box86
cd box86
mkdir build; cd build; cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j$(nproc)
sudo make install
cd ~ && rm -r box86
|
- 使用樹莓派參數編譯Box64
1
2
3
4
5
6
7
| cd ~/
git clone https://github.com/ptitSeb/box64.git
cd box64 && mkdir build && cd build
cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j$(nproc)
sudo make install
cd ~ && rm -r box64
|
Wine用於執行32位元(x86)的exe;Wine64則是執行64位元exe。
ARM環境下,i386架構的Wine用套件管理員是裝不起來的。此處是直接下載Wine的執行檔,並用符號連結的模式安裝。
- 建立目錄
- 從Kron4ek’s Wine-Builds下載Wine和Wine64:
1
| wget https://github.com/Kron4ek/Wine-Builds/releases/download/8.12/wine-8.12-amd64.tar.xz
|
- 解壓縮,並建立符號連結,安裝完成。
1
2
3
4
5
6
7
8
9
10
11
| tar -xvf wine-8.12-amd64.tar.xz
mv ~/wine-8.12-amd64/ ~/wine
rm -rf wine-8.12-amd64.tar.xz
sudo ln -s ~/wine/bin/wine64 /usr/local/bin/wine64
sudo ln -s ~/wine/bin/wine /usr/local/bin/wine
sudo ln -s ~/wine/bin/wineboot /usr/local/bin/wineboot
sudo ln -s ~/wine/bin/winecfg /usr/local/bin/winecfg
sudo ln -s ~/wine/bin/wineserver /usr/local/bin/wineserver
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
sudo mv winetricks /usr/local/bin/
sudo chmod +x /usr/local/bin/wine /usr/local/bin/wineboot /usr/local/bin/winecfg /usr/local/bin/wineserver
|
你可以開啟Proot的Firefox下載Windows exe,或者複製手機的檔案到Proot Linux裡面 (Linux開啟檔案管理員 → 檔案系統,/sdcard
目錄便是手機內部儲存空間的目錄)
執行程式前要確認你的exe是32位元或64位元版。
例如下載了Notepad++32位元版,在含有exe的目錄按右鍵開啟終端機:
1
| box86 wine notepad++.exe
|
等待幾秒後Notepad++的視窗便會開啟。
以此類推,如果是64位元版程式:
1
| box64 wine64 notepad++.exe
|
你可以在執行Wine64指令前先宣告WINEPREFIX
,這樣會新建一個目錄,將不同的執行環境區隔開來:
1
2
3
| export WINEPREFIX=~/.wine64
export WINEARCH=win64
box64 wine64 notepad++.exe
|