ubuntu 20.04编译安装Wine
ubuntu20.04通过源码安装wine, 同时处理安装过程中的问题
一、wine是什么
Wine (“Wine Is Not an Emulator” 的首字母缩写)是一个能够在多种 POSIX-compliant 操作系统(诸如 Linux,macOS 及 BSD 等)上运行 Windows 应用的兼容层。Wine 不是像虚拟机或者模拟器一样模仿内部的 Windows 逻辑,而是將 Windows API 调用翻译成为动态的 POSIX 调用,免除了性能和其他一些行为的内存占用,让你能够干净地集合 Windows 应用到你的桌面。
二、准备工作
1、系统信息:
[15:29:31 (11) jacob@jacob-hp ~] $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
2、编译准备
需要安装git, make等工具
三、源码下载、编译
如果不使用32位应用,仅看这一部分就可以,如果需要支持32位应用,请移步到第四部分。
1、源码下载
git clone https://gitlab.winehq.org/wine/wine.git
2、编译
2.1 执行configure
进入wine目录, 执行./configure
2.1.1 如果出现以下报错:
configure: error: Cannot build a 32-bit program, you need to install 32-bit development libraries.
解决方案:
./configure --enable-win64
2.1.2 如果出现以下报错:
checking for X... no
configure: error: X 64-bit development files not found. Wine will be built
without X support, which probably isn't what you want. You will need
to install 64-bit development packages of Xlib at the very least.
Use the --without-x option if you really want this.
解决方案:
sudo apt-get install xorg-dev libx11-dev
2.2 执行make
2.3 执行sudo make install
3、运行
3.1 winecfg
会出现乱码
对应的解决方案: 下载相关字体放在对应位置
可以通过如下链接下载字体:
git clone https://github.com/gasharper/linux-fonts.git
然后将simsun.ttc文件复制到~/.wine/drive_c/windows/Fonts
之后创建一个文件,内容如下, 名字可以随意取,比如reg.reg:
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
"Arial"="simsun"
"Arial CE,238"="simsun"
"Arial CYR,204"="simsun"
"Arial Greek,161"="simsun"
"Arial TUR,162"="simsun"
"Courier New"="simsun"
"Courier New CE,238"="simsun"
"Courier New CYR,204"="simsun"
"Courier New Greek,161"="simsun"
"Courier New TUR,162"="simsun"
"FixedSys"="simsun"
"Helv"="simsun"
"Helvetica"="simsun"
"MS Sans Serif"="simsun"
"MS Shell Dlg"="simsun"
"MS Shell Dlg 2"="simsun"
"System"="simsun"
"Tahoma"="simsun"
"Times"="simsun"
"Times New Roman CE,238"="simsun"
"Times New Roman CYR,204"="simsun"
"Times New Roman Greek,161"="simsun"
"Times New Roman TUR,162"="simsun"
"Tms Rmn"="simsun"
接着执行:
regedit reg.reg
现在打开winecfg之后查看乱码的部分就正常了。
四、软件使用
一、32位软件
当前安装方式不支持32位软件的执行,会出现以下报错:
0074:err:vulkan:get_vulkan_driver Wine was built without Vulkan support.
0114:err:environ:init_peb starting L"Z:\\home\\jacob\\Desktop\\clientsetup_demo.exe" in experimental wow64 mode
wine: failed to load L"\\??\\C:\\windows\\syswow64\\ntdll.dll" error c0000135
无法启动程序,或者没有为指定文件关联应用程序。
ShellExecuteEx 失败: 内部错误。
于是重新进行编译支持32位的wine, 先执行make distclean命令,在执行./configure会出现如下错误
checking for X... no
configure: error: X 64-bit development files not found. Wine will be built
without X support, which probably isn't what you want. You will need
to install 64-bit development packages of Xlib at the very least.
Use the --without-x option if you really want this.
需要安装libc6-dev-i386和lib32z1(ia32-libs被lib32z1取代),在执行./configure
sudo apt install libx11-dev:i386 lib32z1
如果出现如下报错:
configure: error: FreeType 32-bit development files not found. Fonts will not be built.
Use the --without-freetype option if you really want this.
安装对应的软件:
sudo apt-get install libfreetype6-dev:i386
如果依旧报错:
sudo apt-get install libfreetype6-dev gobject* libxrender-dev libfontconfig-dev pthread* libpthread-stubs0-dev xext* libsm-dev
处理完成之后,继续执行./configure, 执行完成之后,执行make命令,如果出现如下报错:
gcc -m32 -o tools/winegcc/winegcc tools/winegcc/utils.o tools/winegcc/winegcc.o -ldl
/usr/bin/ld: i386:x86-64 architecture of input file `tools/widl/hash.o' is incompatible with i386 output
collect2: error: ld returned 1 exit status
make: *** [Makefile:197614:tools/widl/widl] 错误 1
make: *** 正在等待未完成的任务....
进入源码目录,按照如下顺序执行命令:
make distclean
unset CFLAGS
unset LDFLAGS
export CFLAGS="-m32"
export LDFLAGS="-L./lib32"
rm -f lib32
mkdir -p ./lib32
ln -s /usr/lib32/mesa/libGL.so.1 ./lib32/libGL.so
./configure --verbose
make -j8 && sudo make install
安装完成之后,32位应用可以执行,但是发现无法执行64位应用, 于是重新下载一份源码, 之后执行如下命令:
./configure --enable-win64 --prefix=/opt/wine64/
make -j8
sudo make install
安装完成之后,进入/opt/wine64/bin目录,发现wine和wine64都可以正常执行,对应于32位和54位的应用都可以正常执行。
到此,整个wine的安装结束。
更多推荐
所有评论(0)