mac安装wine

copy: MacOS/Building - WineHQ Wiki

Dependencies

Once you have Xcode and a version of the X11 server (not required but highly recommended), you need to grab both the build and runtime dependencies for Wine. While you can just run Wine's configure script and keep installing libraries that it complains are missing, using a package manager will save you a lot of trouble and keep your system cleaner.

 The main caveat with the various macOS package repos is that you do not want to mix them. Once you've decided to use one, stick with it, and if you decide to switch to a different one, it's probably best to uninstall all of your old packages first, then reinstall them with the new system.

 The subsections below describe ways you can get just the necessary dependencies for Wine. If you want, you can always just install the appropriate wine package, which will pull in all the other packages you need. At that point, you can either uninstall just the wine package, or keep it and run your own build from within its directory.

homebrew

homebrew no longer provide a wine formula instead opting to use their cask system to install Winehq provided packages.

Build dependencies;

brew install --formula bison mingw-w64 pkgconfig

Runtime dependencies;

brew install —-formula freetype gnutls molten-vk sdl2

Please note Homebrew doesn’t add bison to $PATH so this needs to be handled manually.

MacPorts

The current wine packages available from Macports are obsolete so can’t be used as a reference for needed build/runtime dependencies. Here’s an updated list for wine-8.x

Built-time dependency list: 

sudo port install bison \
                  mingw-w64 \
                  pkgconfig

Runtime dependency list:

sudo port install freetype \
                  gnutls \
                  moltenvk \
                  libsdl2

Please Note: 
For macOS Mojave and below use the following options +universal -x11 
macOS Mojave you need to do some workarounds to enable 32Bit builds see #56991 (wine cannot be built against the 10.14 SDK) – MacPorts

Building from Source

download page:Index of /wine/source/8.0

package:wine-8.0.2.tar.xz

Now with the dependencies installed, you will use almost the same procedure as described on the Building Wine page. You should be able to run ./configure and make with the same parameters as on another system.

Note: Almost all libraries are correctly detected and configured by pkgconfig.

You can configure your build directory to compile with clang like so:

./configure CC="clang" CXX="clang++" --enable-win64 --without-freetype

Note: The minimum SDK to compile wine is MacOSX10.10.SDK (14D125). The final SDK to support 32Bit is MacOSX10.13.SDK later SDKs support 64Bit and arm64 (MacOSX11.1.SDK and later for arm64)


Please Note: Wine uses standard dlopen() to find libraries meaning wine will only check standard location /usr/local/lib & /usr/lib so wine will have trouble finding the needed libraries when using macports and XQuartz. To avoid this let’s use rpath.

LDFLAGS=“-Wl,-rpath,/opt/X11/lib”

Note: The provided example when set during configure will ensure wine checks /opt/X11/lib for any needed libraries before the standard locations.

Running a Custom Build

When installing Wine from source on macOS, you may need to make some quick configuration changes.

 After compiling Wine from source, you can install it into /usr/local with make install, but it's highly recommended that you run it from the build directory.

Depending on how you installed XQuartz, you might see fatal errors in X11 when you try to run your own build of wine from the command-line. This is due to XQuartz installing into the /opt/X11/ directory and creating symlinks to /usr/X11/, neither of which is typically checked by the macOS dynamic linker. There are a couple of workarounds for this:

  • The first is to add the usr/X11/lib directory to the DYLD_FALLBACK_LIBRARY_PATH environment variable. You can do this when invoking wine like so:
DYLD_FALLBACK_LIBRARY_PATH="${DYLD_FALLBACK_LIBRARY_PATH}:/usr/lib:/usr/X11/lib" wine program_name.exe
  • The other method is to create symlinks to the libraries in usr/X11/lib/ from inside /usr/local/lib:
cd /usr/local/lib
sudo ln -s /usr/X11/lib/*

However, this second approach is more tedious to undo and may be more fragile in some situations.

 You might need to tweak the actual directories in your list, but you can avoid the tedium of typing the list every time by setting it in one of your shell config files (e.g. .profile.bash_profile, or .bashrc):

export DYLD_FALLBACK_LIBRARY_PATH="${DYLD_FALLBACK_LIBRARY_PATH}:/usr/lib:/usr/X11/lib"

 Joerg Hoehle proposed patching the winewrapper to adjust DYLD_FALLBACK_LIBRARY_PATH every time wine is invoked. For some reason, the patch was rejected (perhaps changing PATH variables or symlinking should be done upstream by XQuartz?)

你可能感兴趣的:(macos,wine)