Wine (简体中文)
Wine 是一款可以在类 unix 操作系统上运行微软 Windows 应用程序的兼容层。在 Wine 中运行的程序可以像本地程序一样运行,而不会像模拟器那样影响性能/内存。
- Wine并非与你的系统分离。
- 如果您可以使用您的用户帐户访问文件或资源,那么在 Wine 中运行的程序也可以。参见#Running Wine under a separate user account和Security#sandboxing applications了解可能的预防措施。
- Wine 也可以运行恶意软件(参见 Wine常见问题)
安装
可以通过启用multilib 库来 安装 wine(开发版),wine-stableAUR (稳定) 或 wine-staging (测试) 软件包。 Wine Staging是Wine的修补版本, 其中包含了bug修复和尚未集成到稳定或开发分支中的特性。
可以考虑为依赖于 Internet Explorer 和 .NET 的应用程序分别安装wine-gecko和wine-mono。这两个软件包不是需要强制安装的依赖,因为Wine会根据需要自行下载相关文件。反过来说,如果提前安装了软件包,Wine就不需要再下载文件了。
第三方Wine应用
这些都有自己的社区和网站,并不受主要Wine社区的支持。详见Wine Wiki。
- CrossOver — Wine 的付费商业版,提供更全面的终端用户支持。
- exe-thumbnailer — 为 Windows 可执行文件(exe、lnk、msi和dll格式)生成缩略图。
- Lutris — 所有类型游戏的游戏启动器,包括 Wine 游戏(带前缀管理)、原生 Linux 游戏和模拟器。
- PlayOnLinux — Wine 的图形化前缀管理器。包含帮助程序安装和配置的脚本。
- Proton — 基于Wine和其它部件,为[Wikipedia:Steam]制造的Proton兼容性工具。兼容性列表见 ProtonDB list.
- PyWinery — Wine 的简单图形化前缀管理器。
- Q4Wine — Wine 的图形前缀管理器。可以将 Qt 主题导出到 Wine 配置中,以便更好地集成。
- Bottles — 基于 GTK 的 Wine 的图形化前缀和管理器。
配置
配置Wine通常使用以下方法:
-
winecfg 是 Wine 的 GUI 配置工具,可以通过运行
winecfg
启动它。 -
regedit 是 Wine 的注册表编辑工具,可以通过运行
regedit
来启动。See WineHQ's article on Useful Registry Keys. -
control 是 Wine 的 Windows 控件面板的实现,它可以通过运行
wine control
来启动。 - 完整列表见 WineHQ 的命令列表。
WINEPREFIX
默认情况下,Wine 将其配置文件和安装的 Windows 程序存储在 ~/.wine
,通常会把此目录叫作“Wine prefix”或“Wine bottle”。当您运行 Windows 程序或 Wine 的捆绑程序(如 winecfg)时,它会自动创建/更新。前缀目录还包含一个目录,您的 Windows 程序将其视为 c:
(C盘)。
您可以使用 WINEPREFIX
环境变量覆盖 Wine 使用的前缀位置。如果您希望为不同的 Windows 程序使用单独的配置,这将非常有用。第一次运行带有新 Wine 前缀的程序时,Wine 将自动创建一个带有 c 驱动器和注册表的目录。
例如,如果您运行一个带有$ env WINEPREFIX=~/.win-a wine program-a.exe
的程序,和另一个 $ env WINEPREFIX=~/.win-b wine program-b.exe
这两个程序将分别有一个单独的 c 驱动器和单独的注册。
{{注意: Wine不是沙盒!在 Wine 下运行的程序仍然可以访问系统的其余部分!(例如, Z:
映射到 /
, 与 Wine 前缀无关)}}
若要在不运行 Windows 程序或其他 GUI 工具的情况下创建默认前缀,可以使用:
$ env WINEPREFIX=~/.customprefix wineboot -u
WINEARCH
Wine will start a 64-bit environment by default. You can change this behavior using the WINEARCH
environment variable. Rename your ~/.wine
directory and create a new Wine environment by running $ WINEARCH=win32 winecfg
. This will get you a 32-bit Wine environment. Not setting WINEARCH
will get you a 64-bit one.
You can combine this with WINEPREFIX
to make a separate win32
and win64
environment:
$ WINEARCH=win32 WINEPREFIX=~/win32 winecfg $ WINEPREFIX=~/win64 winecfg
You can also use WINEARCH
in combination with other Wine programs, such as winetricks (using Steam as an example):
WINEARCH=win32 WINEPREFIX=~/.local/share/wineprefixes/steam winetricks steam
In order to see the architecture of an existing prefix you can check its registry file. The command below reads the system registry of the ~/.wine
prefix and returns #arch=win32
or #arch=win64
depending on the architecture type:
$ grep '#arch' ~/.wine/system.reg
图形驱动程序
You need to install the 32-bit version of your graphics driver. Please install the package that is listed in the OpenGL (multilib) column in the table in Xorg#Driver installation.
A good sign that your drivers are inadequate or not properly configured is when Wine reports the following in your terminal window:
Direct rendering is disabled, most likely your OpenGL drivers have not been installed correctly
声音
By default sound issues may arise when running Wine applications. Ensure only one sound device is selected in winecfg.
Install the correct packages for the audio driver you want to use:
- For ALSA install lib32-alsa-lib and lib32-alsa-plugins
- For PulseAudio install lib32-libpulse
- For PipeWire install either pipewire-pulse and lib32-libpulse or pipewire-alsa and lib32-alsa-lib + lib32-alsa-plugins
- For OSS install lib32-alsa-oss
Additional packages:
- Games that use advanced sound systems (e.g. TESV: Skyrim) may additionally require installations of lib32-openal.
If winecfg still fails to detect the audio driver (Selected driver: (none)), configure it via the registry. For example, in a case where the microphone was not working in a 32-bit Windows application on a 64-bit stock install of wine-1.9.7, this provided full access to the sound hardware (sound playback and mic): open regedit, look for the key HKEY_CURRENT_USER → Software → Wine → Drivers, and add a string called Audio and give it the value alsa. Also, it may help to recreate the prefix.
MIDI支持
在90年代,MIDI是相当流行的游戏音乐系统。尝试游玩老游戏时,音乐可能无法直接播放。 Wine对MIDI有良好的支持,但首先需要让它在系统上工作,如MIDI中所解释的。最后,需要确保Wine使用了正确的MIDI输出。
其它依赖
对于以下情况,部分应用软件可能需要额外的软件包:
- 播放音乐: lib32-mpg123
- 原生图像处理库: lib32-giflib and lib32-libpng
- 加密服务: lib32-gnutls
- 32位视频编解码器: lib32-gst-plugins-base, lib32-gst-plugins-good, lib32-gst-plugins-badAUR and lib32-gst-plugins-uglyAUR
- NTLM身份验证: samba
字体
如果 Wine 应用程序没有显示易读的字体,则可能没有安装任何字体。轻松链接所有的系统字体,使其可以从Wine:
$ cd ${WINEPREFIX:-~/.wine}/drive_c/windows/Fonts && for i in /usr/share/fonts/**/*.{ttf,otf}; do ln -s "$i" ; done
Wine 使用 FreeType 渲染字体,而 FreeType 的默认设置在几个版本之前已经改变了。尝试在Wine项目中使用这种环境设置:
FREETYPE_PROPERTIES="truetype:interpreter-version=35"
另一种可能性是在Wine前缀中安装微软的 TrueType 字体。 See MS Fonts. If this does not help, try running winetricks corefonts
first, then winetricks allfonts
as a last resort.
运行此类程序后,关闭所有 Wine 服务并运行 winecfg
。字体现在应该是可读的。
如果字体看起来模糊不清,导入以下文本文件到 Wine 注册表regedit:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Wine\X11 Driver] "ClientSideWithRender"="N"
对于高分辨率显示,可以在 winecfg 中调整 dpi 值。
另见Font configuration#Applications without fontconfig support。
启用平滑字体
提高Wine渲染效果的一个好方法是使用cleartype平滑字体。 若要启用“次像素平滑(ClearType) RGB”:
$ cat << EOF > /tmp/fontsmoothing REGEDIT4 [HKEY_CURRENT_USER\Control Panel\Desktop] "FontSmoothing"="2" "FontSmoothingOrientation"=dword:00000001 "FontSmoothingType"=dword:00000002 "FontSmoothingGamma"=dword:00000578 EOF $ WINE=${WINE:-wine} WINEPREFIX=${WINEPREFIX:-$HOME/.wine} $WINE regedit /tmp/fontsmoothing 2> /dev/null
详见[1]。
桌面启动器
当使用 Windows 应用安装程序创建一个快捷方式时,Wine 会创建 .desktop 文件。Arch Linux 中这些文件的默认位置是:
- 桌面快捷方式位于
~/Desktop
下。 - 开始菜单图标位于
~/.local/share/applications/wine/Programs/
下。
/usr/share/applications
下。详见 WineHQ bug 11112
wine winemenubuilder
也许能帮得上忙。为Wine utilities创建菜单项
默认情况下,Wine 的安装不会为 Wine 附带的软件创建桌面菜单/图标(例如“ winecfg”、“ winebroserer”等)。这可以通过安装 wine-installerAUR或 wine-installer-gitAUR meta-package (后者没有附加依赖项)来实现,否则这些说明将为这些应用程序添加条目。
首先,使用 Wine 安装一个 Windows 程序来创建基本菜单。创建基本菜单后,可以在 ~/.local/share/applications/wine/
:
wine-browsedrive.desktop
[Desktop Entry] Name=Browse C: Drive Comment=Browse your virtual C: drive Exec=wine winebrowser c: Terminal=false Type=Application Icon=folder-wine Categories=Wine;
wine-uninstaller.desktop
[Desktop Entry] Name=Uninstall Wine Software Comment=Uninstall Windows applications for Wine Exec=wine uninstaller Terminal=false Type=Application Icon=wine-uninstaller Categories=Wine;
wine-winecfg.desktop
[Desktop Entry] Name=Configure Wine Comment=Change application-specific and general Wine options Exec=winecfg Terminal=false Icon=wine-winecfg Type=Application Categories=Wine;
并在~/.config/menus/applications-merged/
目录下创建如下文件:
wine.menu
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN" "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd"> <Menu> <Name>Applications</Name> <Menu> <Name>wine-wine</Name> <Directory>wine-wine.directory</Directory> <Include> <Category>Wine</Category> </Include> </Menu> </Menu>
如果这些设置产生了一个难看的/不存在的图标,这意味着在您所启用的图标集中没有这些启动程序的图标。您应该将图标设置替换为所需图标的位置。单击启动器属性菜单中的图标将会产生同样的效果。一个支持这些快捷方式的图标集是GNOME-colors。
由 Wine 创建的菜单条目位于 ~/.local/share/applications/wine/Programs/
.
除了通过 Wine 删除不需要的扩展绑定,还可以执行以下命令(摘自 Wine 官网) :
$ rm ~/.local/share/mime/packages/x-wine* $ rm ~/.local/share/applications/wine-extension* $ rm ~/.local/share/icons/hicolor/*/*/application-x-wine-extension* $ rm ~/.local/share/mime/application/x-wine-extension*
Sometimes you should also remove wine-*.menu
files from /.config/menus/
to completely remove items from wine submenu in kde.
主题
类似于 xp 外观的主题可以在这里 下载. To install it, see this upstream wiki article. Lastly, use winecfg to select it.
Zune
folder and Zune.theme
files from drive_c/Windows/Resources/Themes
in that prefix to the same location in your usual prefix.Wine staging users may instead want to try enabling the option Enable GTK3 Theming under the Staging section of winecfg for a theme that matches the current GTK theme.
打印
In order to use your installed printers (both local and network) with wine applications in win32 prefixes (e.g. MS Word), install the lib32-libcups package, reboot wine (wineboot) and restart your wine application.
网络
After installation, the lib32-gnutls package may need to be installed for applications making TLS or HTTPS connections to work.
For ICMP (ping), Wine may need the network access as described in the WineHQ FAQ:
# setcap cap_net_raw+epi /usr/bin/wine-preloader
If issues arise after this (such as an unhandled exception or privileged instruction), remove via:
# setcap -r /usr/bin/wine-preloader
使用
See Wine User's Guide for general information on Wine usage.
See Wine Application Database (AppDB) for additional information on specific Windows applications in Wine.
Wayland
Currently Wine does not support Wayland directly, but you can use XWayland instead.
There are some efforts to support Wayland though:
- Experimental Wayland driver for Wine, which supports using OpenGL- and Windows GDI-applications. See this and this wine-devel maillist entries.
- wine-wayland: a custom version of Wine, which supports Wayland via Vulkan (so it supports only: DirectX 9, 10 and 11 via #DXVK and Vulkan-compatible applications).
提示与技巧
Wineconsole
Often you may need to run .exe's to patch game files, for example a widescreen mod for an old game, and running the .exe normally through Wine might yield nothing happening. In this case, you can open a terminal and run the following command:
$ wineconsole cmd
Then navigate to the directory and run the .exe file from there.
Winetricks
Winetricks is a script to allow one to install base requirements needed to run Windows programs. Installable components include DirectX 9.x, MSXML (required by Microsoft Office 2007 and Internet Explorer), Visual Runtime libraries and many more.
Install the winetricks package (or alternatively winetricks-gitAUR). Then run it with:
$ winetricks
For using GUI you should install the zenity.
性能
CSMT
CSMT is a technology used by Wine to use a separate thread for the OpenGL calls to improve performance noticeably. Since Wine 3.2, CSMT is enabled by default. However, CSMT support needs to be enabled manually for Wine versions lower than 3.2. For vanilla Wine run wine regedit
and set the DWORD value for HKEY_CURRENT_USER -> Software > Wine > Direct3D > csmt to 0x01 (enabled). For wine-staging run winecfg
and enable it in the staging tab.
Note that CSMT may actually hurt performance for some applications - if this is the case, disable it by creating/setting the registry value to 0x00 (disabled).
Further information:
- Phoronix Forum discussion with the CSMT developer Stefan Dösinger
强制使用OpenGL模式运行游戏
Some games might have an OpenGL mode which may perform better than their default DirectX mode. While the steps to enable OpenGL rendering is application specific, many games accept the -opengl
parameter.
$ wine /path/to/3d_game.exe -opengl
You should of course refer to your application's documentation and Wine's AppDB for such application specific information.
DXVK
DXVK is a promising new implementation for DirectX 9, 10 & 11 over Vulkan. This should allow for greater performance, and in some cases, even better compatibility. Battlefield 1 for example, only runs under DXVK. On the other hand, DXVK does not support all Wine games (yet).
To use it, install dxvk-binAUR. Then run the following command to activate it in your Wineprefix (by default ~/.wine
):
$ WINEPREFIX=your-prefix setup_dxvk install
Gallium Nine
With the open-source gallium-based drivers (mostly AMD and Intel cards) there is a Gallium Direct3D state tracker that aims to provide nearly-native performance for DirectX 9. In most cases it has less visual glitches than the upstream wine and doubles the performances. It consumes much less CPU time than CSMT.
Install wine-nine to use it. This is a standalone package that can be installed with any Wine version. Use wine ninewinecfg
to check if it is enabled.
For older Intel graphics (gen4-7: GMA 3000, GMA 4500, HD 2000-5000; year 2006-2014) Crocus Gallium driver should be used instead of i965 since Mesa 21.2. Export the following environment variable before running Wine:
MESA_LOADER_DRIVER_OVERRIDE=crocus
Unregister existing Wine file associations
By default, Wine takes over as the default application for a lot of formats. Some (e.g. vbs
or chm
) are Windows-specific, and opening them with Wine can be a convenience. However, having other formats (e.g. gif
, jpeg
, txt
, js
) open in Wine's bare-bones simulations of Internet Explorer and Notepad can be annoying.
Wine's file associations are set in ~/.local/share/applications/
as wine-extension-extension.desktop
files. Delete the files corresponding to the extensions you want to unregister. Or, to remove all wine extensions:
$ rm -f ~/.local/share/applications/wine-extension*.desktop $ rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
Next, remove the old cache:
$ rm -f ~/.local/share/applications/mimeinfo.cache $ rm -f ~/.local/share/mime/packages/x-wine* $ rm -f ~/.local/share/mime/application/x-wine-extension*
And, update the cache:
$ update-desktop-database ~/.local/share/applications $ update-mime-database ~/.local/share/mime/
Please note Wine will still create new file associations and even recreate the file associations if the application sets the file associations again.
Prevent Wine from creating filetype associations
/usr/share/wine/wine.inf
.This method prevents the creation of filetype associations but retains the creation of XDG .desktop files (that you might see e.g. in menus).
If you want to stop wine from creating filetype associations via winecfg you have to uncheck the "Manage File Associations" checkbox under the Desktop Integration tab. See Wine FAQ
To make the same change via registry add the string Enable
with value N
under:
HKEY_CURRENT_USER\Software\Wine\FileOpenAssociations
You might have to create the key FileOpenAssociations
first!
To make this change via the command-line, run the following command:
$ wine reg add "HKEY_CURRENT_USER\Software\Wine\FileOpenAssociations" /v Enable /d N
If you want to apply this by default for new WINEPREFIXES, edit /usr/share/wine/wine.inf
and add this line for example under the [Services]
section:
HKCU,"Software\Wine\FileOpenAssociations","Enable",2,"N"
To prevent a package upgrade from overriding the modified file, create a pacman hook to make the change automatically:
/etc/pacman.d/hooks/stop-wine-associations.hook
[Trigger] Operation = Install Operation = Upgrade Type = Path Target = usr/share/wine/wine.inf [Action] Description = Stopping Wine from hijacking file associations... When = PostTransaction Exec = /bin/sh -c '/usr/bin/grep -q "HKCU,\"Software\\\Wine\\\FileOpenAssociations\",\"Enable\",2,\"N\"" /usr/share/wine/wine.inf || /usr/bin/sed -i "s/\[Services\]/\[Services\]\nHKCU,\"Software\\\Wine\\\FileOpenAssociations\",\"Enable\",2,\"N\"/g" /usr/share/wine/wine.inf'
See Pacman#Hooks
Execute Windows binaries with Wine implicitly
The wine package installs a binfmt file which will allows you to run Windows programs directly, e.g. ./myprogram.exe
will launch as if you had typed wine ./myprogram.exe
. Service starts by default on boot, if you have not rebooted after installing Wine you can start systemd-binfmt.service
to use it right away.
Dual Head with different resolutions
If you have issues with dual-head setups and different display resolutions you are probably missing lib32-libxrandr.
Also installing lib32-libxinerama might fix dual-head issues with wine (for example, unclickable buttons and menus of application in the right most or bottom most monitor, not redrawable interface of application in that zone, dragging mouse cursor state stucked after leaving application area).
Burning optical media
To burn CDs or DVDs, you will need to load the sg
kernel module.
Proper mounting of optical media images
Some applications will check for the optical media to be in drive. They may check for data only, in which case it might be enough to configure the corresponding path as being a CD-ROM drive in winecfg. However, other applications will look for a media name and/or a serial number, in which case the image has to be mounted with these special properties.
Some virtual drive tools do not handle these metadata, like fuse-based virtual drives (Acetoneiso for instance). CDemu will handle it correctly.
游戏内覆盖显示帧数
Wine features an embedded FPS monitor which works for all graphical applications if the environment variable WINEDEBUG=fps
is set. This will output the framerate to stdout. You can display the FPS on top of the window thanks to osd_cat
from the xosd package. See winefps.sh for a helper script.
Running Wine under a separate user account
It may be desirable to run Wine under a specifically created user account in order to reduce concerns about Windows applications having access to your home directory.
First, create a user account for Wine:
# useradd -m -s /bin/bash wineuser
Now switch to another TTY and start your X WM or DE as you normally would or keep reading...
xhost
command under your main user.Afterwards, in order to open Wine applications using this new user account you need to add the new user to the X server permissions list:
$ xhost +SI:localuser:wineuser
Finally, you can run Wine via the following command, which uses env
to launch Wine with the environment variables it expects:
$ sudo -u wineuser env HOME=/home/wineuser USER=wineuser USERNAME=wineuser LOGNAME=wineuser wine arguments
It is possible to automate the process of running Windows applications with Wine via this method by using a shell script as follows:
/usr/local/bin/runaswine
#!/bin/bash xhost +SI:localuser:wineuser sudo -u wineuser env HOME=/home/wineuser USER=wineuser USERNAME=wineuser LOGNAME=wineuser wine "$@"
Wine applications can then be launched via:
$ runaswine "C:\path\to\application.exe"
In order to not be asked for a password each time Wine is run as another user the following entry can be added to the sudoers file: mainuser ALL=(wineuser) NOPASSWD: ALL
. See Sudo#Configuration for more information.
It is recommended to run winecfg
as the Wine user and remove all bindings for directories outside the home directory of the Wine user in the "Desktop Integration" section of the configuration window so no program run with Wine has read access to any file outside the special user's home directory.
Keep in mind that audio will probably be non-functional in Wine programs which are run this way if PulseAudio is used. See PulseAudio/Examples#Allowing multiple users to share a PulseAudio daemon for information about allowing the Wine user to access the PulseAudio daemon of the principal user.
Temp directory on tmpfs
To prevent Wine from writing its temporary files to a physical disk, one can define an alternative location, like tmpfs. Remove Wine's default directory for temporary files and creating a symlink:
$ rm -r ~/.wine/drive_c/users/$USER/Temp ~/.wine/drive_c/windows/temp $ ln -s /tmp/ ~/.wine/drive_c/users/$USER/Temp $ ln -s /tmp/ ~/.wine/drive_c/windows/temp
Prevent installing Mono/Gecko
If Gecko and/or Mono are not present on the system nor in the Wine prefix, Wine will prompt to download them from the internet. If you do not need Gecko and/or Mono, you might want to disable this dialog, by setting the WINEDLLOVERRIDES
environment variable to mscoree=d;mshtml=d
.
Vulkan
The default Wine Vulkan ICD loader works fine for most applications, but does not support advanced features, like Vulkan layers. To use these features, you have to install the official Vulkan SDK, see step 2-4 on the original Vulkan patches author's GitHub page.
Remove Wine file bindings
For security reasons it may be useful to remove the preinstalled Wine bindings so Windows applications cannot be launched directly from a file manager or from the browser (Firefox offers to open EXE files directly with Wine!).
If you want to do this, you may add the following to the [options]
section in /etc/pacman.conf
NoExtract = usr/lib/binfmt.d/wine.conf NoExtract = usr/share/applications/wine.desktop
WineASIO
If you need professional audio support under wine you can use wineasioAUR which provides an ASIO interface for wine that you can then use with JACK.
In order to use wineasio you must add yourself to the realtime
user group.
Next you need to register wineasio in your desired wine prefix. Register the 32-bit and/or 64-bit version as needed:
$ regsvr32 /usr/lib32/wine/i386-windows/wineasio.dll $ wine64 regsvr32 /usr/lib/wine/x86_64-windows/wineasio.dll
疑难解答
See Wine User's Guide and Wine FAQ (especially its Troubleshooting section) for general tips.
Also refer to the Wine AppDB for an advice on specific applications.
XWayland问题
If you use Wine under XWayland, you can activate the option for "Emulating a virtual desktop" in the Graphics Tab in winecfg, to avoid problems with:
- flickering;
- wrong window location;
- wrong mouse cursor location and clicks;
- keyboard detection.
键盘输入不工作
This could be caused by the window manager not switching focus. In the Graphics tab of winecfg, disable the 'Allow the window manager...' options, or set windowed mode with 'Emulate a virtual desktop'.
- Some suggest to toggle all the Window settings, click Apply, then change them back. If that does not work, try the above.
If the keyboard does not work after unfocusing the application, try editing the registry:
- Under HKEY_CURRENT_USER\Software\Wine\X11 Driver, add a string value UseTakeFocus and set it to N.
- Alternatively, you can use winetricks to set the value.
winetricks usetakefocus=n
另见
- Wine Homepage
- Wine Wiki
- Wine Application Database (AppDB) - Information about running specific Windows applications (Known issues, ratings, guides, etc tailored to specific applications)
- Wine Forums - A great place to ask questions after you have looked through the FAQ and AppDB
- Gentoo:Wine
- Darling - a similar project for MacOS software
- WineASIO - GitHub page of the WineASIO project with further information