在ubuntu22.04中安装及使用wine


在ubuntu中安装wine

某些应用程序只能在Windows和MacOS系统中安装使用,如果需要在Ubuntu下使用windows平台的应用程序,需要用Wine程序,Wine是一个开源兼容层,支持在诸如Linux,FreeBSD和MacOS等UNIX的操作系统上运行Windows应用程序。本文记录在Ubuntu22.04下安装Wine的过程。对于ubuntu其他版本也大都适用。

首先执行以下命令更新包列表:

sudo dpkg --add-architecture i386
sudo apt update

在这里插入图片描述

再依次运行下列命令:

wget -qO- https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
sudo apt install software-properties-common
sudo apt-add-repository "deb http://dl.winehq.org/wine-builds/ubuntu/ $(lsb_release -cs) main"

在这里插入图片描述在这里插入图片描述

最后运行下列命令安装wine最新稳定版本,虽然带宽足够,但是下载速度很慢,只有20+kb/s, 需要等待很长时间(下了很久才下完)。

sudo apt install --install-recommends winehq-stable

在这里插入图片描述
在这里插入图片描述

安装完成后,调用wine --version查看版本,目前最新稳定版本为9.0。至此,Wine安装完毕。

wine --version

在 Ubuntu 上初始化 Wine 环境

步骤 1:配置 Wine 环境

安装完成后,需要配置 Mono 等环境,以便让 Wine 能运行 .NET 应用:
输入以下命令:

winecfg

在这里插入图片描述
按提示安装 Mono 及相关依赖。
在这里插入图片描述

步骤 2: 配置 Wine 设置

配置完成后,会自动弹出「Wine 设置」对话框。在这里选择要模拟的 Windows 版本,默认为 Windows 10,可根据需求自行更改。
在这里插入图片描述
调整「音效」、「显示」等设置后,点击「确定」关闭对话框完成配置。

步骤 3: 安装 Winetricks(优化 Wine 使用体验)

Winetricks 是一个辅助脚本,可以帮助你轻松安装和管理 Windows 应用程序和库:

安装 Winetricks

wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks

添加可执行权限

利用chmod命令给winetricks文件添加可执行权限。命令及结果如下:

sudo chmod +x winetricks 

运行

winetricks可以通过命令行运行,在行末指定要安装的东西。但是大部分情况下,你都不知道 .dll 文件或者是你想安装字体确切的名字,因此最好是利用图形界面程序。启动这个程序和其它程序没什么不同,就是在末尾什么都别输入就行了。如下所示:

./winetricks 

注:如果想在任意路径下直接执行winetricks,则可以将winetricks脚本文件放入/usr/local/bin/目录下。

如果出现以下错误:warning: WINE is wine, which is neither on the path nor an executable file

则说明/usr/local/bin/下不存在wine这个可执行文件。笔者是因为之前编译安装的是wine64,因此/usr/local/bin/下只存在wine64。解决方法是在/usr/local/bin/下做一个软链接,使wine指向wine64。如下所示:

sudo ln -s /usr/local/bin/wine64 /usr/local/bin/wine
 
ls -l /usr/local/bin/wine

错误解决后或者没出现错误的情况下,终端输出如下:

./winetricks

warning: You are using a 64-bit WINEPREFIX. Note that many verbs only install 32-bit versions of packages. If you encounter problems, please retest in a clean 32-bit WINEPREFIX before reporting a bug.

Using winetricks 20230212-next - sha256sum: 8f8e5595d76dd220fe71ba06cda65cd81223f2305cdc9f90560e17b75c01889a with wine-8.1-86-ga8c319cad69 and WINEARCH=win64
 
(zenity:3989249): dbind-WARNING **: 18:08:41.975: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.systemd1.NoSuchUnit: Unit at-spi-dbus-bus.service not found.
winetricks GUI enabled, using zenity 3.43.0
 
(zenity:3989258): dbind-WARNING **: 18:08:41.998: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.systemd1.NoSuchUnit: Unit at-spi-dbus-bus.service not found.
 
(zenity:3989258): Gtk-WARNING **: 18:08:42.029: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
 
(zenity:3989258): Gtk-WARNING **: 18:08:42.051: Could not find the icon 'missing-image-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
        http://icon-theme.freedesktop.org/releases

选择默认的即可
请添加图片描述

同时出现以下界面:点击是,确定即可
在这里插入图片描述
请添加图片描述
点击“确定”按钮, 就会进入到WINE prefix的配置菜单,你可以在这完成所有你要使用 winetricks 完成的事情。 如下所示:
请添加图片描述

使用 Winetricks 安装常用的附加组件,例如:

  1. 安装字体:
    在界面中选择字体选项,打开后安装以下字体
allfonts corefonts cjkfonts

请添加图片描述
请添加图片描述

  1. 安装 相应的windows组件 提升兼容性和游戏性能:
    在界面中选择windows组件选项,打开后安装以下组件:
d3dx9 d3dx10 d3dx11 vb6run vcrun2022 riched20 riched30

请添加图片描述
下载组件中:
请添加图片描述

使用 Wine 运行 Windows 应用程序

要运行 Windows 二进制文件,请右键点击文件选择「使用其它程序打开」,再选择 Wine。当然也可以在winetricks里选择下载里面的windows程序。下面以在 Ubuntu 中安装和使用 Notepad++ 作为示例:

  1. 下载 Noetpad ++ 安装文件。

  2. 右键点击安装文件,选择「使用其它程序打开」。

  3. 选择使用「Wine Windows Program Loader」打开。

在这里插入图片描述
在这里插入图片描述
安装完成后即可使用
在这里插入图片描述

参考文献:
[1]https://blog.csdn.net/m0_69535455/article/details/127938306
[2]https://blog.csdn.net/zhao001101/article/details/127903715
[3]https://www.codenong.com/cs107095843/
[4]https://blog.csdn.net/wei_1020/article/details/127852369
[5]https://blog.csdn.net/weixin_42483745/article/details/125417780
[6]https://blog.csdn.net/gc_2299/article/details/129077372

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值