Wine是讓Linux跑Windows exe程式的轉譯技術。
儘管Wine有支援ARM架構,Raspberry Pi OS套件庫也有收,然而Windows exe大多是x86架構,所以你不可以安裝ARM架構的Wine去跑x86架構的程式。
我們得想辦法搞到x86架構的Wine,交給Box64轉譯,進而執行Windows exe。
1. 安裝Box64與Box86#
2. 安裝Wine#
以Raspberry Pi OS Bookworm 64-Bit
來說,請不要直接用APT硬裝x86版Wine的deb套件,在此,我們使用Box64開發者推薦的的方式,用符號連接將Wine執行檔硬塞到系統裡面。
- Wine目前在16K page會有問題,所以必須在系統啟用4K page
echo '# 4k pages
kernel=kernel8.img
'| sudo tee -a /boot/firmware/config.txt
sudo reboot
- 啟用armhf架構支援
sudo dpkg --add-architecture armhf
sudo apt-get update
- 安裝依賴套件
sudo apt-get install -y libasound2:armhf libc6:armhf libglib2.0-0:armhf libgphoto2-6:armhf libgphoto2-port12:armhf \
libgstreamer-plugins-base1.0-0:armhf libgstreamer1.0-0:armhf libldap-common:armhf libopenal1:armhf libpcap0.8:armhf \
libpulse0:armhf libsane1:armhf libudev1:armhf libusb-1.0-0:armhf libvkd3d1:armhf libx11-6:armhf libxext6:armhf \
libasound2-plugins:armhf ocl-icd-libopencl1:armhf libncurses6:armhf libncurses5:armhf libcap2-bin:armhf libcups2:armhf \
libdbus-1-3:armhf libfontconfig1:armhf libfreetype6:armhf libglu1-mesa:armhf libglu1: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 libc6:armhf libcap2-bin:armhf
sudo apt-get install -y libasound2:arm64 libc6:arm64 libglib2.0-0:arm64 libgphoto2-6:arm64 libgphoto2-port12:arm64 \
libgstreamer-plugins-base1.0-0:arm64 libgstreamer1.0-0:arm64 libldap-common:arm64 libopenal1:arm64 libpcap0.8:arm64 \
libpulse0:arm64 libsane1:arm64 libudev1:arm64 libunwind8:arm64 libusb-1.0-0:arm64 libvkd3d1:arm64 libx11-6:arm64 libxext6:arm64 \
ocl-icd-libopencl1:arm64 libasound2-plugins:arm64 libncurses6:arm64 libncurses5:arm64 libcups2:arm64 \
libdbus-1-3:arm64 libfontconfig1:arm64 libfreetype6:arm64 libglu1-mesa:arm64 libgnutls30:arm64 \
libgssapi-krb5-2:arm64 libjpeg62-turbo:arm64 libkrb5-3:arm64 libodbc1:arm64 libosmesa6:arm64 libsdl2-2.0-0:arm64 libv4l-0:arm64 \
libxcomposite1:arm64 libxcursor1:arm64 libxfixes3:arm64 libxi6:arm64 libxinerama1:arm64 libxrandr2:arm64 \
libxrender1:arm64 libxxf86vm1:arm64 libc6:arm64 libcap2-bin:arm64
# 額外套件
wget -r -l1 -np -nd -A "libfaudio0_*~bpo10+1_i386.deb" http://ftp.us.debian.org/debian/pool/main/f/faudio/
dpkg-deb -xv libfaudio0_*~bpo10+1_i386.deb libfaudio
sudo cp -TRv libfaudio/usr/ /usr/
rm libfaudio0_*~bpo10+1_i386.deb
rm -rf libfaudio
- 下載Wine執行檔。由於WineHQ官網僅提供deb套件,故我們使用預先建置的版本。此處使用 Kron4ek建置的Wine。Box64尚未支援Wine 8.0以上的Wow64功能,故下載Wine 7.0版本。
cd ~
wget https://github.com/Kron4ek/Wine-Builds/releases/download/7.22/wine-7.22-amd64.tar.xz
tar -xvf wine-7.22-amd64.tar.xz
mv wine-7.22-amd64 wine
rm wine-7.22-amd64.tar.xz
- 建立符號連結,將
/usr/local/bin/wine
指向~/wine/bin/wine
,下面的以此類推。
sudo ln -s ~/wine/bin/wine /usr/local/bin/wine
sudo ln -s ~/wine/bin/wine64 /usr/local/bin/wine64
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
sudo chmod +x /usr/local/bin/wine /usr/local/bin/wine64 /usr/local/bin/wineboot /usr/local/bin/winecfg /usr/local/bin/wineserver
3. 安裝Winetricks#
Winetricks只是指令稿,沒有架構之分,直接安裝:
sudo apt-get install cabextract
cd ~/Downloads && wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
sudo chmod +x winetricks && sudo mv winetricks /usr/local/bin/
4. Wine指令用法#
相關文章: Wine指令用法
裝好後就可以用以下組合,啟動Windows exe。啟動前需注意exe是32位元還是64位元。
box64 wine64 <Windows exe執行檔>
box86 wine <Windows exe執行檔>
注意Box86/Box64的3D繪圖圖形指令尚有部份未實作,Winetricks也不太穩定,建議先從簡單的小遊戲開始測試。
如果要區分32位元與64位元環境,可以用WINEPREFIX隔開不同程式的設定檔目錄
# 設定檔位於~/.wine64
WINEPREFIX=~/.wine64 box64 wine64 <Windows exe執行檔>
# 設定檔位於~/.wine,指定32位元
WINEPREFIX=~/.wine WINEARCH=win32 box86 wine <Windows exe執行檔>
同理,Winetricks執行前,最好也先指定要裝到哪個Wine環境:
WINEPREFIX=~/.wine64 box64 winetricks