零、注意事项
本教程仅针对“银河麒麟桌面操作系统 V10(SP1) 2403 版”,如你需要 2303 版本系统的安装教程,请见【ARM版银河麒麟安装windows应用程序】。非 2403 版本系统通过本方法安装可能出现依赖冲突,甚至造成系统损坏(但是不会破坏你的备份,只是桌面进不去,遇到问题直接还原即可)。
请注意,Wine 并不能保证运行所有 Windows 程序,大部分程序不能完美的运行在 Linux 上,甚至可能完全不能运行。
安装前,请尽可能地备份系统,以免发生意外。如果出现依赖冲突,建议还原系统并使用 2303 版本的方法安装。
安装时,不要直接使用 root 账号操作(使用 sudo 而不是 su),否则可能导致安装的 Windows 软件需要 root 权限才能启动(因为 wine 被安装到了 /root 下)。
本教程受到【ARM版银河麒麟安装windows应用程序】的启发,并参考了部分内容。
一、安装 Box86 / Box64 和 Wine
我们需要使用 Wine 运行 .exe 文件,而 Box 能使 Wine 在 ARM64 架构的设备中使用。
创建一个 .sh 脚本文件,粘贴并运行以下代码。这段代码修改自 Box 官方文档 。
执行时,你不需要主动给予它 root 权限。当有需要时,它会提醒你输入密码。
# NOTE: Can only run on aarch64 (since box64 can only run on aarch64)
# box64 runs wine-amd64, box86 runs wine-i386.
### User-defined Wine version variables ################
# - Replace the variables below with your system's info.
# - Note that we need the amd64 version for Box64 even though we're installing it on our ARM processor.
# - Note that we need the i386 version for Box86 even though we're installing it on our ARM processor.
# - Wine download links from WineHQ: https://dl.winehq.org/wine-builds/
branch="staging" #example: devel, staging, or stable (wine-staging 4.5+ requires libfaudio0:i386)
version="9.16" #example: "7.1"
id="ubuntu" #example: debian, ubuntu
dist="focal" #example (for debian): bullseye, buster, jessie, wheezy, ${VERSION_CODENAME}, etc
tag="-1" #example: -1 (some wine .deb files have -1 tag on the end and some don't)
########################################################
# Add Box64 Source
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
# Add Box86 Source
sudo dpkg --add-architecture armhf # enable multi-arch
sudo wget https://itai-nelken.github.io/weekly-box86-debs/debian/box86.list -O /etc/apt/sources.list.d/box86.list
wget -qO- https://itai-nelken.github.io/weekly-box86-debs/debian/KEY.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/box86-debs-archive-keyring.gpg
# Update Sources
sudo apt update
# Install Boxes
sudo apt install box86 box64 -y
# Clean up any old wine instances
wineserver -k # stop any old wine installations from running
rm -rf ~/.cache/wine # remove any old wine-mono/wine-gecko install files
rm -rf ~/.local/share/applications/wine # remove any old program shortcuts
# Backup any old wine installs
rm -rf ~/wine-old 2>/dev/null; mv ~/wine ~/wine-old 2>/dev/null
rm -rf ~/.wine-old 2>/dev/null; mv ~/.wine ~/.wine-old 2>/dev/null
sudo mv /usr/local/bin/wine /usr/local/bin/wine-old 2>/dev/null
sudo mv /usr/local/bin/wine64 /usr/local/bin/wine-old 2>/dev/null
sudo mv /usr/local/bin/wineboot /usr/local/bin/wineboot-old 2>/dev/null
sudo mv /usr/local/bin/winecfg /usr/local/bin/winecfg-old 2>/dev/null
sudo mv /usr/local/bin/wineserver /usr/local/bin/wineserver-old 2>/dev/null
# Wine download links from WineHQ: https://dl.winehq.org/wine-builds/
# LNKA="https://dl.winehq.org/wine-builds/${id}/dists/${dist}/main/binary-amd64/" #amd64-wine links
LNKA="https://mirrors.tuna.tsinghua.edu.cn/wine-builds/${id}/dists/${dist}/main/binary-amd64/" #amd64-wine links
DEB_A1="wine-${branch}-amd64_${version}~${dist}${tag}_amd64.deb" #wine64 main bin
DEB_A2="wine-${branch}_${version}~${dist}${tag}_amd64.deb" #wine64 support files (required for wine64 / can work alongside wine_i386 main bin)
# DEB_A3="winehq-${branch}_${version}~${dist}${tag}_amd64.deb" #shortcuts & docs
# LNKB="https://dl.winehq.org/wine-builds/${id}/dists/${dist}/main/binary-i386/" #i386-wine links
LNKB="https://mirrors.tuna.tsinghua.edu.cn/wine-builds/${id}/dists/${dist}/main/binary-i386/" #i386-wine links
DEB_B1="wine-${branch}-i386_${version}~${dist}${tag}_i386.deb" #wine_i386 main bin
DEB_B2="wine-${branch}_${version}~${dist}${tag}_i386.deb" #wine_i386 support files (required for wine_i386 if no wine64 / CONFLICTS WITH wine64 support files)
# DEB_B3="winehq-${branch}_${version}~${dist}${tag}_i386.deb" #shortcuts & docs
# Install amd64-wine (64-bit) alongside i386-wine (32-bit)
echo -e "Downloading wine . . ."
wget ${LNKA}${DEB_A1}
wget ${LNKA}${DEB_A2}
wget ${LNKB}${DEB_B1}
echo -e "Extracting wine . . ."
dpkg-deb -x ${DEB_A1} wine-installer
dpkg-deb -x ${DEB_A2} wine-installer
dpkg-deb -x ${DEB_B1} wine-installer
echo -e "Installing wine . . ."
mv wine-installer/opt/wine* ~/wine
# Download wine dependencies
# - these packages are needed for running box86/wine-i386 on a 64-bit RPiOS via multiarch
sudo apt-get install -y libasound2:armhf libasound2-plugins:armhf libc6:armhf libcairo2:armhf libcap2-bin:armhf \
libcups2:armhf libdbus-1-3:armhf libfontconfig1:armhf libfreetype6:armhf libglib2.0-0:armhf libglu1-mesa:armhf \
libgnutls30:armhf libgphoto2-6:armhf libgphoto2-port12:armhf libgssapi-krb5-2:armhf libgstreamer1.0-0:armhf \
libgstreamer-plugins-base1.0-0:armhf libgtk-3-0:armhf libkrb5-3:armhf libncurses6:armhf libodbc1:armhf \
libosmesa6:armhf libpcap0.8:armhf libpcsclite1:armhf libpulse0:armhf libsane:armhf libsdl2-2.0-0:armhf libudev1:armhf \
libusb-1.0-0:armhf libv4l-0:armhf libva2:armhf libva-drm2:armhf libva-x11-2:armhf libx11-6:armhf libxcomposite1:armhf \
libxcursor1:armhf libxext6:armhf libxfixes3:armhf libxi6:armhf libxinerama1:armhf libxrandr2:armhf libxrender1:armhf \
libxxf86vm1:armhf ocl-icd-libopencl1:armhf # to run wine-i386 through box86:armhf on aarch64
# This list found by downloading...
# wget https://dl.winehq.org/wine-builds/debian/dists/bullseye/main/binary-i386/wine-devel-i386_7.1~bullseye-1_i386.deb
# wget https://dl.winehq.org/wine-builds/debian/dists/bullseye/main/binary-i386/winehq-devel_7.1~bullseye-1_i386.deb
# wget https://dl.winehq.org/wine-builds/debian/dists/bullseye/main/binary-i386/wine-devel_7.1~bullseye-1_i386.deb
# then `dpkg-deb -I package.deb`. Read output, add `:armhf` to packages in dep list, then try installing them on Pi aarch64.
# - these packages are needed for running box64/wine-amd64 on RPiOS (box64 only runs on 64-bit OS's)
sudo apt-get install -y libasound2:arm64 libasound2-plugins:arm64 libc6:arm64 libcap2-bin:arm64 libcups2:arm64 \
libdbus-1-3:arm64 libfontconfig1:arm64 libfreetype6:arm64 libgcc-s1:arm64 libglib2.0-0:arm64 libglu1-mesa:arm64 \
libgnutls30:arm64 libgphoto2-6:arm64 libgphoto2-port12:arm64 libgssapi-krb5-2:arm64 libgstreamer1.0-0:arm64 \
libgstreamer-plugins-base1.0-0:arm64 libgtk-3-0:arm64 libkrb5-3:arm64 libncurses6:arm64 libodbc1:arm64 \
libosmesa6:arm64 libpcap0.8:arm64 libpcsclite1:arm64 libpulse0:arm64 libsane:arm64 libsdl2-2.0-0:arm64 libudev1:arm64 \
libusb-1.0-0:arm64 libv4l-0:arm64 libva2:arm64 libva-drm2:arm64 libva-x11-2:arm64 libx11-6:arm64 libxcomposite1:arm64 \
libxcursor1:arm64 libxext6:arm64 libxfixes3:arm64 libxi6:arm64 libxinerama1:arm64 libxrandr2:arm64 libxrender1:arm64 \
libxxf86vm1:arm64 ocl-icd-libopencl1:arm64
# This list found by downloading...
# wget https://dl.winehq.org/wine-builds/debian/dists/bullseye/main/binary-amd64/wine-devel_7.1~bullseye-1_amd64.deb
# wget https://dl.winehq.org/wine-builds/debian/dists/bullseye/main/binary-amd64/wine-devel-amd64_7.1~bullseye-1_amd64.deb
# then `dpkg-deb -I package.deb`. Read output, add `:arm64` to packages in dep list, then try installing them on Pi aarch64.
# Install symlinks
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
三、初始化 Wine
使用以下命令对 wine 进行初始化。
wine64 wineboot
你可能会被要求安装 Wine Mono ,该组件允许你运行 .Net 程序,请根据需求安装。
由于无法通过换源解决下载速度问题,可能导致安装时间极长,如有必要请使用代理服务器。注意,如果你在此时在设置中修改了系统代理设置,请重启终端,否则可能导致代理不生效。
如果没有合适的代理服务器,可以在官网下载安装包手动安装。
至此,你的设备已经可以安装和运行 Windows 程序。
# 使用 Wine32
wine <可执行文件路径>
# 配置 Wine32
wine winecfg
# 使用 Wine64
wine64 <可执行文件路径>
# 配置 Wine64
wine64 winecfg
由于环境不完整,部分软件可能无法正常运行。
如果你的软件出现了闪退、报错、中文不显示等情况,请根据以下步骤补全环境。
四、安装 Winetricks
使用以下命令安装最新版本的 Winetricks ,更多相关内容(如自动更新脚本)请见官方仓库。
wget https://raw.githubusercontents.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo mv winetricks /usr/local/bin
如果你需要使用图形界面,还需安装 Zenity 。
sudo apt install zenity -y
你可能需要的字体:
- allfonts
- corefonts
- cjkfonts
你可能需要的软件:
- d3dx9
- d3dx10
- d3dx11
- vb6run
- vcrun2022
- riched20
- riched30
由于部分文件存储于 Github 和 archive.org ,你可能需要使用代理服务器才能下载和安装。