ubuntu 安装 wine

ubuntu 18.04 安装 wine 使用企业微信

介绍

因为目前企业微信没有 linux 版本,希望在 ubuntu 18.04 上使用企业微信,所以探索使用 wine 来在 ubuntu 上运行企业微信。

ubuntu 18.04 安装 wine

启用 32 位架构

1
sudo dpkg --add-architecture i386

配置 wine 仓库

1
2
sudo wget -nc -O /usr/share/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo sh -c "echo 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/winehq-archive.key] https://mirrors.tuna.tsinghua.edu.cn/wine-builds/ubuntu/ bionic main' > /etc/apt/sources.list.d/winehq.list"

修改 /usr/share/keyrings/winehq-archive.key 权限

1
sudo chmod 644 /usr/share/keyrings/winehq-archive.key

更新镜像源

1
sudo apt update

安装 wine 最新稳定版

1
sudo apt -y install --install-recommends winehq-stable

查看 wine 版本

1
wine --version

使用32位模式启动 winecfg

1
WINEARCH=win32 WINEPREFIX=~/.wine winecfg

因为 wine 缺少语言包,所以中文显示会乱码,解决:将 windows 系统 C:\Windows\Fonts 中的语言文件拷贝到 ~/.wine/drive_c/windows/Fonts/ 目录

1
2
sudo unzip Fonts.zip
sudo cp ./Fonts/* ~/.wine/drive_c/windows/Fonts/

winecfg 启动是提示安装 wine-mono 和 wine-gecko,如果在线安装失败,可以使用离线安装

下载 wine-mono 和 wine-gecko

1
2
wget http://mirrors.ustc.edu.cn/wine/wine/wine-mono/7.4.0/wine-mono-7.4.0-x86.msi
wget http://mirrors.ustc.edu.cn/wine/wine/wine-gecko/2.47.4/wine-gecko-2.47.4-x86.msi

安装 wine-mono 和 wine-gecko

1
2
wine start wine-mono-7.4.0-x86.msi
wine start wine-gecko-2.47.4-x86.msi

安装 winetricks

1
2
3
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
sudo chmod +x winetricks 
sudo mv winetricks /usr/local/bin

使用32位模式启动 winetricks

1
WINEARCH=win32 WINEPREFIX=~/.wine winetricks

使用 winetricks 安装组件时,如果安装失败,经常是因为下载的文件不完整(SHA256 mismatch!),所以需要我们单独下载文件,拷贝到相应的位置

使用 winetricks 安装 windows 组件

  • 安装 riched20
    • 安装 riched20 时,需要提前安装 cabextract

      1
      
      sudo apt-get -y install cabextract
      
    • 使用 winetrick 下载 W2KSP4_EN.EXE 文件不完整

      • 手动下载,地址:http://x3270.bgp.nu/download/specials/W2KSP4_EN.EXE
      • 将 W2KSP4_EN.EXE 拷贝到 ~/.cache/winetricks/win2ksp4/ 目录
    • 使用 winetrick 下载 InstMsiW.exe 文件不完整

      • 手动下载,地址:https://web.archive.org/web/20160710055851if_/http://download.microsoft.com/download/WindowsInstaller/Install/2.0/NT45/EN-US/InstMsiW.exe
      • InstMsiW.exe 拷贝到 ~/.cache/winetricks/msls31 目录
    • 安装 riched20

  • 安装 riched30
    • 使用 winetrick 下载 InstMsiA.exe 文件不完整
      • 手动下载,地址:https://web.archive.org/web/20060720160141/https://download.microsoft.com/download/WindowsInstaller/Install/2.0/W9XMe/EN-US/InstMsiA.exe
      • InstMsiA.exe 拷贝到 ~/.cache/winetricks/riched30
    • 安装 riched30
  • 安装 richtx32
    • 提前安装 7zip
      • ubuntu 安装 7zip: sudo apt-get install p7zip-full
    • 安装 richtx32
  • 安装 windowscodecs
    • 若使用 winetrick 下载 wic_x86_enu.exe 文件不完整
      • 手动下载,地址:https://web.archive.org/web/20200810071051if_/https://download.microsoft.com/download/f/f/1/ff178bb1-da91-48ed-89e5-478a99387d4f/wic_x86_enu.exe
      • wic_x86_enu.exe 拷贝到 ~/.cache/winetricks/windowscodecs
    • 安装 windowscodecs

安装企业微信

1
WINEARCH=win32 WINEPREFIX=~/.wine wine WeCom_3.1.6.3605.exe

经过测试

企业微信安装成功后,在收藏夹中存在两个企业微信图标,位置:

1
2
~/.local/share/applications/wine/Programs/企业微信/企业微信.desktop
~/.local/share/applications/wine/企业微信.desktop

删掉一个即可

1
rm -rf ~/.local/share/applications/wine/企业微信.desktop

安装 topicons

使用 wine 安装企业微信后,企业微信图标会以悬浮窗的形式显示,可以安装Gnome Shell插件 TopIcons Plus 解决问题,将 wine 中软件的图标整合到 ubuntu gnome 托盘。

安装方式一(推荐):
安装 gnome shell 扩展

1
sudo apt install gnome-shell-extension-top-icons-plus

安装方式二:

编译安装

  • 根据 ubuntu 使用的 GONME 版本,下载对应的 topicons
  • ubuntu 18.04.6 使用的 GNOME 版本为 3.28.2
  • topicons 下载地址:https://extensions.gnome.org/extension/1031/topicons/
  • Download 3.28 22
  • 安装 make 编译工具
    1
    
    sudo apt-get -y install make
    
  • 编译安装
    1
    
    sudo make install
    

安装后重启gnome alt+f2 输入 r 重启 gnome

问题:无法显示企业微信图标

问题:

  1. sudo echo 权限不够

    希望将文本写入到某个文件中(若这个文件不存在,自动创建该文件)

    使用 sudo echo "" > file 时提示权限不够

    1
    2
    
    $ sudo echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/winehq-archive.key] https://mirrors.tuna.tsinghua.edu.cn/wine-builds/ubuntu/ bionic main" > /etc/apt/sources.list.d/winehq.list
    bash: /etc/apt/sources.list.d/winehq.list: 权限不够
    

    解决:

    1. 使用 sh -c "sudo echo '' > file",如
      1
      
      $ sudo sh -c "echo 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/winehq-archive.key] https://mirrors.tuna.tsinghua.edu.cn/wine-builds/ubuntu/ bionic main' > /etc/apt/sources.list.d/winehq.list"
      
    2. 使用 echo "" | sudo tee file,如:
      1
      
      $ echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/winehq-archive.key] https://mirrors.tuna.tsinghua.edu.cn/wine-builds/ubuntu/ bionic main" | sudo tee /etc/apt/sources.list.d/winehq.list
      
      使用 echo "" | sudo tee -a file,进行追加文本,等同于 >>
  2. 使用 wine 安装微信时提示 ntlm_check_version ntlm_auth was not found

    wine 安装微信

    1
    
    WINEARCH=win32 wine ./WeChatSetup.exe
    

    错误信息:

    1
    
    03f0:err:winediag:ntlm_check_version ntlm_auth was not found. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.
    

    解决:

    1
    
    sudo apt-get install -y winbind
    
  3. Cannot find cabextract. Please install it (e.g. 'sudo apt-get install cabextract' or 'sudo yum install cabextract').

    解决: 安装 cabextract

    1
    
    apt-get install cabextract
    
  4. Note: command cabextract -q --directory=/home/hekai/.wine/dosdevices/c:/windows/temp /home/hekai/.cache/winetricks/msls31/InstMsiW.exe returned status 1. Aborting.

    原因:
    winetricks 自动下载的 InstMsiW.exe 文件不完整

    解决:
    手动下载 InstMsiW.exe,然后拷贝到 ~/.cache/winetricks/msls31

  5. Note: command cabextract -q --directory=/home/ctyun/.wine/dosdevices/c:/windows/temp /home/ctyun/.cache/winetricks/riched30/InstMsiA.exe returned status 1. Aborting.

    原因:
    winetricks 自动下载的 InstMsiA.exe 文件不完整

    解决:
    手动下载 InstMsiA.exe,然后拷贝到 ~/.cache/winetricks/riched30

  6. 使用 wine 安装微信失败

    1
    2
    3
    4
    
    $ WINEARCH=win32 wine ./WeChatSetup.exe
    0118:fixme:seh:WerRegisterMemoryBlock (530AA498 6144) stub
    0118:fixme:seh:WerRegisterMemoryBlock (530A4000 4) stub
    0118:err:ole:apartment_getclassobject DllGetClassObject returned error 0x80040154 for dll L"C:\\windows\\system32\\windowscodecs.dll"
    

    解决: 使用 winetricks 安装 windowscodecs

  7. 更新apt源报错

    1
    2
    3
    4
    5
    
    $ sudo apt update
    获取:1 http://security.debian.org/debian-security buster/updates InRelease [34.8 kB]
    获取:2 https://mirrors.tuna.tsinghua.edu.cn/wine-builds/ubuntu bionic InRelease [6,263 B]
    错误:2 https://mirrors.tuna.tsinghua.edu.cn/wine-builds/ubuntu bionic InRelease
      由于没有公钥,无法验证下列签名: NO_PUBKEY 76F1A20FF987672F
    

    参考: https://blog.csdn.net/weixin_44172434/article/details/89160720

    1
    
    $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 76F1A20FF987672F
    

    执行后,还是报错

    发现 /usr/share/keyrings/winehq-archive.key 文件权限是 660,同目录下其他文件权限是644,将 winehq-archive.key 文件权限修改为 644 后就可以执行 sudo apt update 了。

参考:
https://wiki.winehq.org/Ubuntu
https://mirrors-i.tuna.tsinghua.edu.cn/help/wine-builds/
https://cloud.tencent.com/developer/article/1626683
https://mirrors-i.tuna.tsinghua.edu.cn/help/wine-builds/
https://blog.csdn.net/amnesiagreen/article/details/116791833
https://blog.csdn.net/cxrshiz7890/article/details/106185468
https://blog.csdn.net/qq_45945548/article/details/124123820
https://blog.csdn.net/cxrshiz7890/article/details/106042837
https://blog.csdn.net/Hsin96/article/details/119147144

Built with Hugo
主题 StackJimmy 设计