wine for MacOS
Installing Wine on Mac
This tutorial is for intermediate users who want to install and use Wine on their computer running macOS. You should already know the basics of how to use the command line. If you don't, read this tutorial first.
- What is Wine?
- Will My Program Work With Wine?
- Requirements
- Part 1: Install Homebrew
- Part 2: Install XQuartz Using Homebrew
- Part 3: Install Wine Using Homebrew
- Part 4: Install Windows Programs Using Wine
- Part 5: Run Windows Programs Using Wine
- Making a Dock Icon
- Keeping Wine Up to Date
- Uninstalling Wine and Homebrew
What is Wine?
Wine is awesome. No, I'm not talking about the kind you drink, I mean the kind that lets you run Windows apps without the Windows operating system. It's kind of Zen, when you think about it. Oh, and did I mention it's completely free, legal, and open source?
Nowadays, Windows and Mac play nicely together. You can install Windows and Mac side by side and switch between them using Boot Camp, but that requires a reboot every time, and you can only use one operating system at a time. You can also use a tool like Parallels Desktop or VMware Fusion to virtualize Windows and run it together with Mac, but virtualization is slow and it takes up a lot of memory. (Your physical computer creates an imaginary "virtual" computer within itself, and runs Windows on that. That takes a lot of resources!) On top of that, all of these solutions require you to own a legal copy of Windows, which isn't cheap!
Wine is different. When any program runs, it requests resources like memory and disk space from the operating system. All that Wine does is make sure that those requests get answered so that the program can run correctly. As far as the program knows, everything is going smoothly because it has everything it needs. It never even realizes that it's not running on Windows! It's simpler than emulating a whole new computer, so it's faster. Since it's just translating requests, you don't need a copy of the actual Windows operating system. Plus, Wine is open source, which means people are continually improving it and adding new features. And you can't beat the price!
Will My Program Work With Wine?
A lot of people discover Wine because they have one specific Windows program that they need to use, and it's the last thing preventing them from switching to a different operating system. So, the big question is, will it work? The short answer is: probably, but it's worth checking.
The Wine project maintains a database called the AppDB that has user reviews of how well specific Windows programs work under Wine. Search for your program and find out! (If it's not listed, that doesn't necessarily mean that it won't work — only that you're apparently trying to use a very obscure program!)
Requirements
To install Wine on your Mac, you will need the following:
- macOS 10.10 (Yosemite) or above
- Access to an Admin account, with password
- An internet connection
To check what version of macOS you're running, click on the Apple logo on the far left side of the toolbar, select "About This Mac", and look at your version number under the big "macOS" or "OS X". If it's 10.10 or higher, you're all set.
You need an Admin account on your Mac because only Admins can install software. You will need to be logged in to this Admin account during the installation. If there is only one account on your computer, it is an Admin account. The account must have a password: if the account has no password, the sudoutility will fail. To set or change your password, go to the Accounts section in System Preferences.
Part 1: Install Homebrew
Homebrew is a package manager that makes installing open source programs much easier. In particular, trying to install a large program like Wine without the help of a package manager would be tremendously difficult. Fortunately, Homebrew itself is simple to install: just open up the Terminal and run this command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The Terminal will tell you what it's about to do, and ask you if you want to proceed: press Enter to do so. The Terminal may then ask for a password: this is the password to the Admin account on your computer. As a security measure, the Terminal does not display anything as you type, not even asterisks (*). Type your password anyway, and press Enter. If you get some kind of error, it might be because the Admin account doesn't have a password set. Setting a password is required.
Installing Homebrew should only take a few seconds or minutes (depending on the speed of your internet connection). When it's done, the Terminal will say that the installation was successful, and ask you to run brew doctor. Do as it suggests:
brew doctor
This will make Homebrew inspect your system and make sure that everything is set up correctly. If the Terminal informs you of any issues, you'll need to fix them yourself, and then run brew doctor again to verify that you fixed them correctly. When everything is set up correctly, you'll see the message Your system is ready to brew, and you can move on to the next part of the tutorial.
Note: If Homebrew tells you that you need to agree to the Xcode license, you can do that by running:
sudo xcodebuild -license
The Terminal window will fill up with the Xcode license: read it, type agree and hit enter to agree to the license.
Part 2: Install XQuartz Using Homebrew
Wine needs XQuartz to install correctly, and Homebrew won't automatically pull in this dependency for you. However, we can easily ask Homebrew to install it by running the following command:
brew cask install xquartz
Let's break down this command into parts. brew refers to Homebrew, which you just installed. caskrefers to Homebrew Cask, an extension to Homebrew that is used to install GUI application on your computer. (GUI stands for "Graphical User Interface". A GUI application is an app that you can seerunning, as opposed to invisibly running in the background.) install refers to the fact that you're asking Homebrew Cask to install something on your computer, and xquartz is the name of the thing that you want it to install. We only need to include the word cask because XQuartz is a GUI application — by default, you use Homebrew to install applications that run on the command line, and don't have a graphical user interface.
When you run this command, Homebrew will install the Cask extension automatically, and then Homebrew Cask will download and install XQuartz for you. (Lots of installers installing other installers!) Homebrew will display messages and progress bars on the Terminal to let you know what it's doing. When it's done installing XQuartz, it will stop displaying messages and wait for you to type in a new command. When that happens, move on to the next step!
Part 3: Install Wine Using Homebrew
Now we get to actually install Wine! We'll let Homebrew do all the work, all you have to do is tell it what you want with this command:
brew install wine
You'll notice that this command is almost identical to the last one, except we're leaving out the word cask (because Wine doesn't have a graphical user interface), and we're replaced xquartz with wine.
When you run this command, Homebrew will start automatically downloading and installing software onto your computer. Wine needs several different pieces of software to run correctly, not just XQuartz, so Homebrew is going to first install those other dependencies before it installs Wine. Just as before, Homebrew will display messages and progress bars on the Terminal to let you know what it's doing.
This step of the tutorial might be very quick, or it might take a long, long time. You see, software like Wine normally needs to be compiled: transformed from human-readable source code into a form that a computer can use. This process usually takes a long time — for a program like Wine and all of its depedencies, it might take an hour or two, even for a fast, modern computer. However, the people who make Homebrew know that people don't like to wait, and they've pre-compiled most of the software available in Homebrew, including Wine. Your computer will automatically download the pre-compiled versions if it is able to, which will make the installation process go a lot faster. However, if your computer is in an unusual configuration, it may not be able to use the pre-compiled versions. If that's the case, it will have to compile the software for itself, which will still work, but it will take awhile.
If you get an error message at this step that indicates that Homebrew has accidentally downloaded a file that is empty or incorrect, you can delete Homebrew's downloaded files by running brew cleanup. Then try running this step again, and Homebrew will redownload the file — hopefully correctly!
When Homebrew is finished installing Wine, it will stop displaying messages and wait for you to type in a new command. You may see a message that mentions a "Mac driver" and an "X11 driver". This message is related to that XQuartz thing we installed earlier, and it's an advanced configuration for people who like to adjust settings on their computers. If you just want to use Wine and don't care about adjusting settings, you can ignore that message.
Part 4: Install Windows Programs Using Wine
To install a Windows program, first download the installer file: it should end with .exe. Remember the location you put it, and open up the Terminal again. cd to the location, and use ls to make sure you can see the installer file. (Note: if you do not know what cd and ls are, you should learn how to use the command line before using Wine.)
Once you are in the correct directory, run the installer through Wine by running the following command in the Terminal:
wine $INSTALLER.exe
Where $INSTALLER is the name of the installer file. For example, if the installer file is named setup.exe, you would run:
wine setup.exe
A window will pop up with a regular graphical Windows installer. Click through it, and you're done!
Part 5: Run Windows Programs Using Wine
Open up the Terminal and run this to get to your Program Files folder:
cd ~/.wine/drive_c/Program\ Files/
Run ls to see what programs you have installed. Pick a program, and enter its directory using cd. (If the folder has a space in it, you must type a \ before the space. For example, Program\ Files. If you're having problems, try using tab autocomplete.) There should be a file that ends in .exe: this is the program file. Type this into Terminal:
wine $PROGRAM.exe
Where $PROGRAM is the name of the .exe file. For example, if the program file is named STARCRAFT.EXE, you would run:
wine STARCRAFT.EXE
The program will pop up in a new window, ready to use! Enjoy using Windows on your Mac, freely and legally!
Making a Dock Icon
Many people want to be able to run Windows programs the same way they run other programs on the Mac: by clicking an icon in the Dock. Wine isn't specifically designed to support this, but with a little trickery, we can make it do what we want.
Note: Wine prints out error messages in the Terminal when something goes wrong. By launching Windows programs via a Dock icon, you are sidestepping the Terminal, which means that if something does go wrong and Wine has to quit, it will not be able to tell you what the problem was. The first step to solving a problem is knowing what it is, so without running Wine from the Terminal, you won't be able to fix it, and neither will anyone else. Running from the Dock is fine as long as your program seems to be working correctly, but if it crashes, the first thing you should try is running it from the Terminal instead: it won't prevent the program from crashing, but it will give you some clues on how to fix the problem.
In order to launch a Windows program via the Dock, we're going to write an AppleScript that launches the program for us, and then put that AppleScript in the Dock. Essentially, we're writing a program ourselves! Don't worry, it's easy enough. There is a program on your computer that is designed for helping you write AppleScripts: it's called "Script Editor", and you can find it in the /Applications/Utilities directory of your computer, same as the Terminal itself.
Open up the Script Editor. You should see a window with a large area you can type in near the top: this is where you write your AppleScript. In that area, type the following text:
tell application "Terminal"
do script "/usr/local/bin/wine ~/.wine/drive_c/Program\\ Files/$PATH_TO_PROGRAM.exe"
end tell
You'll need to replace $PATH_TO_PROGRAM with the path from the Program Files directory to your program executable. You can see that you're simply telling the AppleScript to run a line of code in the Terminal: the same line of code that you could run to start your Windows program.
Next, press the Compile button at the top of the window. The text should become colored to indicate that Script Editor understands what you wrote. You can also try pressing the Run button to run your script: it should open the Windows program successfully.
Lastly, save your script. You can give it whatever name you'd like, but be sure to select File Format: Application in the save options, and leave Startup Screen unchecked.
Open up the Finder, go to where you saved your script, and drag that file to your Dock. It should stay there, just like a real application — because it is a real application! However, all it does is run that launcher command for you, so you can move the application around, rename it, or even delete it, and it won't affect the Windows program that you're running.
Keeping Wine Up to Date
Wine is an open source program. That means that programmers around the world are continually improving it, adding new features and squashing bugs. If you don't update Wine, though, it will never get those improvements, so it's generally a good idea to check for updates every so often. We can use Homebrew to keep Wine up to date: it's easy! Just run this command:
brew upgrade
With this command, Homebrew will first update itself, if any updates are available. It will then find all the outdated software it knows about (including Wine) and upgrade them all to the latest version. Checking for updates isn't strictly necessary, as Wine runs quite well currently. However, it's a good idea to run this command every few months or so.
Uninstalling Wine and Homebrew
If you try Wine and you don't like it, uninstalling it is easy. Just run this command:
brew uninstall wine
And Homebrew will helpfully remove Wine from your computer. However, in order to install Wine, Homebrew also had to install many other small programs that Wine relies upon to work correctly. (That's why the install process takes so long!) If you want to remove these as well, run this script:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
That script will remove everthing that you installed in this tutorial, including Homebrew, Wine, and all the other programs Homebrew installed to get Wine to work correctly.
wine for MacOS的更多相关文章
- Wine中中文显示为错误的解决方案
First u must download wqy-microhei.ttc font online (https://github.com/anthonyfok/fonts-wqy-microhei ...
- ubuntu18.04安装wine
wine是一个兼容层,可以从多平台(linux,macos,等)运行windows应用. Wine (Wine Is Not an Emulator)[即Wine不是一个模拟器]是一个在Linux和U ...
- Wine和CrossOver之间的关系简单介绍
相信有些小伙伴们不太了解Wine和CrossOver之间的关系与区别,然而对此又很好奇,所以小编今天将给大家介绍一下这两者之间的关系与区别. Wine是什么? Windows.Linux和macOS是 ...
- TODO:macOS编译PHP7.1
TODO:macOS编译PHP7.1 本文主要介绍在macOS上编译PHP7.1,有兴趣的朋友可以去尝试一下. 1.下载PHP7.1源码,建议到PHP官网下载纯净到源码包php-7.1.0.tar.g ...
- TODO:macOS上ThinkPHP5和Semantic-UI集成
TODO:macOS上ThinkPHP5和Semantic-UI集成 1. 全局安装 (on OSX via homebrew)Composer 是 homebrew-php 项目的一部分 2. 把X ...
- CoreCRM 开发实录——Travis-CI 实现 .NET Core 程度在 macOS 上的构建和测试 [无水干货]
上一篇文章我提到:为了使用"国货",我把 Linux 上的构建和测试委托给了 DaoCloud,而 Travis-CI 不能放着不用啊.还好,这货支持 macOS 系统.所以就把 ...
- docker4dotnet #3 在macOS上使用Visual Studio Code和Docker开发asp.net core和mysql应用
.net猿遇到了小鲸鱼,觉得越来越兴奋.本来.net猿只是在透过家里那田子窗看外面的世界,但是看着海峡对岸的苹果园越来越茂盛,实在不想再去做一只宅猿了.于是,.net猿决定搭上小鲸鱼的渡轮到苹果园去看 ...
- ASP.NET Core 中文文档 第二章 指南(1)用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
原文:Your First ASP.NET Core Application on a Mac Using Visual Studio Code 作者:Daniel Roth.Steve Smith ...
- 记录在linux下的wine生活
记录在linux下的windows生活 本篇内容涉及QQ.微信.Office的安装配置 QQ: 到deepin下载轻聊版. 如果安装了crossover,那么将其中opt/cxoffice/suppo ...
随机推荐
- vmware的硬件选项里有关于虚拟化引擎的选项(虚拟机支持硬件虚拟化)
前一阵子在使用陈沙克老师的博客安装devstack的时候就有一个疑问: 使用vmware创建虚拟机时,硬件选项里有关于虚拟化引擎的选项到底都代表了什么意思? Intel VT-x/EPT和AMD-V ...
- WPF学习笔记(2)——动画效果按钮变长
说明(2017-6-12 11:26:48): 1. 视频教程里是把一个按钮点击一下,慢慢变长: 注意几个方面: (1)RoutedEvent="Button.Click",这里面 ...
- java好用的邮件发送
1.action代码 // 发送邮件 String strEMAIL = Tools.readTxtFile(Const.EMAIL); //读取邮件配置 String strEM[] = strEM ...
- mysql的骚操作:自增长的字段同时插入到另一个字段
如题 ' ); select * from information_schema.tables where table_schema ='mytest' and table_name='users'; ...
- C语言 · LOG大侠
标题:LOG大侠 atm参加了速算训练班,经过刻苦修炼,对以2为底的对数算得飞快,人称Log大侠. 一天,Log大侠的好友 drd 有一些整数序列需要变换,Log大侠正好施展法力... 变换的规则是: ...
- python 全局变量的使用
我尝试使用 类似 C 语言的方式去调用 python 的全局变量,发现不行,后经过 尝试,要使用 global 进行调用 test_num = 0; # 首先声明一个全局变量 def test_fun ...
- mac OS X:[11]如何添加打印机
苹果菜单中,单击下拉列表中的『系统偏好设置』: 或在Dock上,单击『系统偏好设置』图标. 2 在『系统偏好设置』窗口中,单击『打印机与扫描仪』图标. 3 在『打印机与扫描仪』窗口中,单击打印机框架下 ...
- RavenDb学习(八)高级特性上半部分
.事务支持 别的关系型数据库和RavenDb一起使用 using (var transaction = new TransactionScope()) { BlogPost entity = sess ...
- 【jquery】基于 jquery 的翻牌效果 flip
最近做了个类似于塔罗牌翻牌的效果,分享给大家. <!doctype html> <html lang="en"> <head> <meta ...
- SpringCloudConfig与SpringCloudEureka 注册中心与配置中心高可用的意义
所有的配置会缓存在本地,远程配置中心DOWN机,不影响本地使用,只是无法重新请求服务端获取配置的更新. 不管是注册中心的高可用,还是配置中心的高可用.本质上都是保证服务能注册上去或者能从配置中心获取配 ...