LoginSignup
5
11

More than 3 years have passed since last update.

M1 Macでのオープンソース版CrossOver 20.0.4のビルドと実行

Last updated at Posted at 2021-02-09

CrossOver

WindowsバイナリをLinuxやmacOS上で動作させることができる商用ソフトのCrossOverはGPLのWineをベースとしているのでソースコードが公開されています。

現時点(2021/2/9)でmacOS Catalina以降で動作するWineは64bit Windowsバイナリのみ対応ですが、CrossOverはllvm/clangベースの特別なコンパイラを使って64bit環境で32bitバイナリを実行するwine32on64により32bit Windowsバイナリと64bit Windowsバイナリの両方を動かすことができます。

以前CrossOver 20.0.2のビルドについて
https://qiita.com/asfdrwe/items/24cf3759edeb3fe56bc0
で解説しましたが、20.0.4になって多少ビルドしやすくなっているのであらためて解説します。

追記

2021/2/14

2019/12頃のwine-develにKen Thomases氏によるwine32on64の技術的な解説と指定すべきビルドオプションの説明を見つけました。
https://www.winehq.org/pipermail/wine-devel/2019-December/156602.html
https://www.winehq.org/pipermail/wine-devel/2019-December/157027.html

ビルド環境構築

~/Download/以下で作業していきます。

$ cd ~/Downloads

Command line tools for XcodeとRosetta2上で動作するx86_64用homebrewをインストールして、Rosetta2環境下で作業します。

$ xcode-select --install
$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ arch -x86_64 /bin/zsh

余計なものが入っているとwine32on64のビルドに失敗したりうまく動かなくなったりするようなので、homebrewでインストールするものは次のものだけにします。また、必要な環境変数の設定をします。

$ brew install cmake bison flex mingw-w64 freetype winetricks
$ brew list
bison       flex        gmp     libpng      p7zip
cabextract  freetype    isl     mingw-w64   unzip
cmake       gettext     libmpc      mpfr        winetricks
$ export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"
$ export MACOSX_DEPLOYMENT_TARGET=10.14

CrossOver 20.0.4のダウンロード

https://www.codeweavers.com/crossover/source
から
https://media.codeweavers.com/pub/crossover/source/crossover-sources-20.0.4.tar.gz
をダウンロードして展開します(Safariだと勝手にgzを伸長するようです)。

tar cvf crossover-sources-20.0.4.tar

llvmのビルド

llvmをビルドしてパスを通します。かなり時間がかかります。

$ cd sources
$ cd clang/llvm
$ mkdir build
$ cd build
$ cmake ../
$ make
$ cd bin
$ export PATH="$(pwd):$PATH"
$ cd ../../../..

clangのビルド

clangをビルドしてパスを通します。こちらもかなり時間がかかります。

$ cd clang/clang
$ mkdir build
$ cd build
$ cmake ../
$ make
$ cd bin
$ export PATH="$(pwd):$PATH"
cd ../../../..

CrossOver Wineのビルド

wine/include/distversion.hが抜けているので次の内容でファイルを作成するか

diff -uNr sources.orig/wine/include/distversion.h sources/wine/include/distversion.h
--- sources.orig/wine/include/distversion.h 1970-01-01 09:00:00.000000000 +0900
+++ sources/wine/include/distversion.h  2021-02-07 17:03:44.000000000 +0900
@@ -0,0 +1,12 @@
+/* ---------------------------------------------------------------
+*   distversion.c
+*
+* Copyright 2013, CodeWeavers, Inc.
+*
+* Information from DISTVERSION which needs to find
+* its way into the wine tree.
+* --------------------------------------------------------------- */
+
+#define WINDEBUG_WHAT_HAPPENED_MESSAGE "This can be caused by a problem in the program or a deficiency in Wine. You may want to check <a href=\"http://www.codeweavers.com/compatibility/\">http://www.codeweavers.com/compatibility/</a> for tips about running this application."
+
+#define WINDEBUG_USER_SUGGESTION_MESSAGE "If this problem is not present under Windows and has not been reported yet, you can save the detailed information to a file using the \"Save As\" button, then <a href=\"http://www.codeweavers.com/support/tickets/enter/\">file a bug report</a> and attach that file to the report."

パッチをdistversion.patchというファイル名で保存して当ててください。

$ patch -p1 < ../distversion.patch

dlls/winecoreaudio.drv/authorization.mのCoreAudio_request_capture_authorizationでコンパイラのclang-8が
落ちるのを回避する修正と--without-vulkanなのにdlls/winvulkan/でコンパイルエラーになるのを
修正するパッチをbuild.patchというファイル名で保存して当ててください。

$ patch -p1 < ../build.patch

wineディレクトリに移動します。

$ cd wine

wine64のビルド

環境変数を設定し64bit Windowsバイナリ用のwine64をビルドして
/usr/local/opt/crossover-20.0.4以下にインストールします。
通常のWineより時間がかかります。

$ export PATH="$(pwd):$PATH"
$ export CC=clang
$ export CXX=clang++
$ mkdir build64
$ cd build64
$ ../configure --prefix=/usr/local/opt/crossover-20.0.4 --enable-win64 --without-x --without-vulkan --disable-mscms
$ make
$ make install
$ cd ..

なお、CFLAGS=-I/usr/local/includeやLDFLAGS=-L/usr/local/lib等の環境変数の設定をする必要がありますが、homebrewでmolten-vkやSPIRV等をインストールしてVulkanを使えるようにwine64をビルドすることはできます。ただ、前述のように、余計なものがシステムに入っていると、wine32on64のビルドに失敗したり、ビルドできても正常に動作しなかったりします。

wine32on64のビルド

WineのWOW64に対応させて32bit Windowsバイナリと64bit Windows
バイナリ両対応となるようにwine32on64をビルドし、
/usr/local/opt/crossover-20.0.4以下にインストールします。wine32on64も通常のWineより時間がかかります。

$ mkdir build32
$ cd build32
$ ../configure --prefix=/usr/local/opt/crossover-20.0.4 --enable-win32on64 --with-wine64=../build64 --without-x --without-vulkan --disable-mscms
$ make
$ make install
$ cd ..

ちなみに、wine32on64を32bit Windowsバイナリのみ対応にする場合は
--with-wine64=../build64を外して--enable-win32on64のみを指定します。

CrossOver Wineの実行

設定

環境変数を設定します。

$ export PATH="/usr/local/opt/crossover-20.0.4/bin:$PATH"
$ export WINE=/usr/local/opt/crossover-20.0.4/bin/wine64

先にwine64を実行してWineのWOW64環境対応の~/.wine/を作成してください。

$ wine64 winecfg

winetricksで日本語フォントをインストールします。

$ winetricks fonts ipamona fakejapanese_ipamona

Monoが入っていないのでWineHQよりmonoのmsiファイルをダウンロードしてインストールしてください。wine-mono-5.1.1-x86.msiで動くことを確認しています。

$ wine32on64 msiexec /i wine-mono-5.1.1-x86.msi

動作確認したもの

7zip

7zipは32bit版も64bit版も動作しました。

PPSSPP

PSPエミュレータのPPSSPPはOpenGLとDirectX9のバックエンドは動作しました。DirectX11は落ちます。VulkanはCrossOverをVulkan対応でビルドしていないので選択できません。PPSSPP自作ソフトストアにあるCave Storyが起動するのを確認しています。

ただ、4kディスプレイのPHILIPS 276E8VJSB/11を使用しているのですが、ディスプレイの解像度の設定によっては表示がおかしくなります。
tmp1.png
の設定(標準設定と同じ)だと次のように表示が左下4分の1になります。
tmp2.png
表示がおかしいだけでボタンは本来の場所をクリックしないとダメです(終了は右下の黒い場所をクリックする)。

拡大しない設定だと
tmp3.png
次のように正常に表示されます。
tmp4.png

vlcも同じようになります。DirectXやOpenGLを使うものは同様におかしくなるようです。4Kディスプレイを使っている人は注意してください。

あとPPSSPP終了時にエラーが出ます。
tmp5.png

その他

aviutil、MangaMeeya、foobar2000、vlcあたりは起動することを確認しています。

5
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
11