Wine2.0-rc5をソースコードからビルドする

Windows10を使っていたPCでブルースクリーンが頻発するようになったので、Windows10をアンインストールしてUbuntuをインストールした。

やっぱりWindowsのソフトを動かしたくなったので、Wineをインストールすることにした。最新版をインストールしてみる。

環境

  • Ubuntu 16.04(64bit)

Wineとは・・・

https://ja.wikipedia.org/wiki/Wine

Wine (ワイン)は、オープンソースの Windows API 実装を通じて、主としてx86アーキテクチャ上のUnix系オペレーティングシステム (OS) においてWindows用アプリケーションをネイティブ動作させることを目標とするプログラム群である。

https://www.winehq.org/

Wineのインストール

今回はホームページにある開発版の最新版であるWine 2.0-rc5をインストールしてみる。

ソースコードをダウンロードして解凍

$ wget http://dl.winehq.org/wine/source/2.0/wine-2.0-rc5.tar.bz2
$ tar -jxvf wine-2.0-rc5.tar.bz2
$ cd wine-2.0-rc5/

64bit版のWineをビルドする場合

$ sudo add-apt-repository ppa:ubuntu-wine/ppa

ソースコードのレポジトリを追加

$ sudo vi /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-xenial.list

deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial main
deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial main
↑コメントアウトを外す

もし見つけられなければ、システム設定→ソフトウェアとアップデート→他のソフトウェア

f:id:akashisn:20181027131750p:plain

http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial main (ソースコード)のところにチェックを入れる

依存パッケージをインストールする

$ sudo apt update
$ sudo apt build-dep wine1.8

configureしてみる

$ ./configure --enable-win64

configureで次のようなメッセージが出たら下のコマンドを実行すると回避できる

configure: libhal 64-bit development files not found, no legacy dynamic device support.

$ wget http://launchpadlibrarian.net/99811656/libhal1_0.5.14-8_amd64.deb 
$ sudo dpkg -i libhal1_0.5.14-8_amd64.deb
$ wget http://launchpadlibrarian.net/99811659/libhal-dev_0.5.14-8_amd64.deb
$ sudo dpkg -i libhal-dev_0.5.14-8_amd64.deb

configure: gstreamer-1.0 base plugins 64-bit development files not found, gstreamer support disabled

$ sudo apt install libgstreamer-plugins-base1.0-dev

configure: libudev 64-bit development files not found, plug and play won't be supported.

$ sudo apt install libudev-dev

もう一度configureしてみて次のように出たら成功

$ ./configure --enable-win64
configure: Finished.  Do 'make' to compile Wine.

次にビルドする

$ make
$ sudo make install

この時makemake -j2などと引数を与えると与えたスレッド数で並列化してくれる

64bit版のWineをビルドしたら、実行コマンド名がwine64となる。

このままだと不具合があるので、wineという名前でシンボリックリンクを作成しとく

$ sudo ln -s /usr/local/bin/wine64 /usr/local/bin/wine

Winetricksの導入

各種ライブラリやフォントなどの導入を簡単にしてくれるWinetricksをインストールする

https://github.com/Winetricks/winetricks/releasesから最新版をダウンロードする

$ sudo apt install cabextract
$ wget https://github.com/Winetricks/winetricks/archive/20170101.tar.gz
$ tar xzvf 20170101.tar.gz
$ cd winetricks-20170101
$ sudo make install

Wine-Monoの導入

.NET Framework環境を提供するwine-monoをインストールする

http://dl.winehq.org/wine/wine-mono/から最新版をダウンロードする

$ wget http://dl.winehq.org/wine/wine-mono/4.6.4/wine-mono-4.6.4.msi
$ sudo mkdir /usr/local/share/wine/mono
$ sudo mv wine-mono-4.6.4.msi /usr/local/share/wine/mono/ 

Wine-Geckoの導入

Internet Explorer の環境を提供するwine-geckoをインストールする

http://dl.winehq.org/wine/wine-gecko/から最新版をダウンロードする

$ wget http://dl.winehq.org/wine/wine-gecko/2.47/wine_gecko-2.47-x86_64.msi
$ sudo mkdir /usr/local/share/wine/gecko
$ sudo mv wine_gecko-2.47-x86_64.msi /usr/local/share/wine/gecko/ 

Wine初期設定

$ echo 'export WINEARCH=win32 winecfg' >> ~/.bashrc
$ echo 'export WINEPREFIX="/home/USER/.wine/"' >> ~/.bashrc
$ winecfg

USERは各自のユーザーネームを入れて実行する

多分、文字化けしてるが後でフォントを入れるのでいい

文字化けするのを治す

フォントをインストールすることで文字化けが治る

 $ winetricks allfonts

Wineの設定

$ winecfg

f:id:akashisn:20181027131822p:plain

WindowsのバージョンをWindows7に変更する

確認

上記のことができたかを確認する

$ wine uninstaller

f:id:akashisn:20181027131835p:plain

このように文字化けがなくなっていてwine-monowine-geckoの最新版がインストールされてることが確認できたらここまで成功

使い方・実行方法

普通に

$ wine hoge.exe
$ chmod +x hoge.exe
$ ./hoge.exe

ともできる

msiの場合は、

$ msiexec /i setup.msi

で実行できる

エラーが出た場合

コマンドラインから実行したら、

例えば、

err:module:import_dll Library MFC42.DLL (which is needed by L"C:\\Program Files\\Microchip\\MPLAB IDE\\KEELOQ\\KeeLoqAlg.dll") not found

のように

err:module:import_dll Library [足りないライブラリ] (which is needed by L"[必要としてるDLL]") not found

という感じにエラーがでるので[足りないライブラリ]Winetricksでインストールしてやる

$ winetricks [足りないライブラリの名前]

今回は、

$ winetricks mfc42

ダイアログではJaを選択する(ドイツ語で「はい」らしい・・・)

.NET Framework をインストールしてみる

.NETには前のバージョンに依存するのがほとんど(.NET4.0は単独でインストールできる)だけど、

.NET Frameworkのインストールでエラーが出ないためにをやっていればWinetricksが自動で必要なバージョンの.NETをインストールしてくれる

Winetricks最高!

.NET4.5のインストール

$ winetricks dotnet45

〜32bit版のWineをビルドする場合〜

64bitのUbuntuに32bit版のWineをビルドしようとしたが、うまく行かなかった・・・

32bitのライブラリをインストールするので32bitのリポジトリを追加する。

$ sudo dpkg --add-architecture i386
$ sudo apt update

configureしてみる

$ ./configure

configureで次のようなメッセージが出たら下のコマンドを実行すると回避できる

configure: error: Cannot build a 32-bit program, you need to install 32-bit development libraries.

$ sudo apt install g++-multilib

configure: error: no suitable flex found. Please install the 'flex' package.

$ sudo apt install flex

configure: error: no suitable bison found. Please install the 'bison' package.

$ sudo apt install bison

configure: error: X 32-bit development files not found. Wine will be built without X support, which probably isn't what you want. You will need to install 32-bit development packages of Xlib/Xfree86 at the very least. Use the --without-x option if you really want this.

$ sudo apt install libx11-dev:i386

configure: error: FreeType 32-bit development files not found. Fonts will not be built.

$ sudo apt install libfreetype6-dev:i386

configure: libxcursor 32-bit development files not found, the Xcursor extension won't be supported.

$ sudo apt install libxcursor-dev:i386

configure: libxi 32-bit development files not found, the Xinput extension won't be supported.

$ sudo apt install libxi-dev:i386

configure: libXxf86vm 32-bit development files not found, XFree86 Vidmode won't be supported.

$ sudo apt install libxxf86vm-dev:i386

configure: libxrandr 32-bit development files not found, XRandr won't be supported.

$ sudo apt install libxrandr-dev:i386

configure: libxinerama 32-bit development files not found, multi-monitor setups won't be supported.

$ sudo apt install libxinerama-dev:i386

configure: libxcomposite 32-bit development files not found, Xcomposite won't be supported.

$ sudo apt install libxcomposite-dev:i386

configure: libGLU 32-bit development files not found, GLU won't be supported.

$ sudo apt install libglu1-mesa-dev:i386

configure: libOSMesa 32-bit development files not found (or too old), OpenGL rendering in bitmaps won't be supported.

$ sudo apt install libosmesa6-dev:i386

configure: OpenCL 32-bit development files not found, OpenCL won't be supported.

$ sudo apt install ocl-icd-opencl-dev:i386

configure: pcap 32-bit development files not found, wpcap won't be supported.

$ sudo apt install libpcap0.8-dev:i386

configure: lib(n)curses 32-bit development files not found, curses won't be supported.

$ sudo apt install libncurses5-dev:i386

configure: libsane 32-bit development files not found, scanners won't be supported.

$ sudo apt install libsane-dev:i386

configure: libv4l 32-bit development files not found.

$ sudo apt install libv4l-dev:i386

configure: libgphoto2 32-bit development files not found, digital cameras won't be supported.

$ sudo apt install libgphoto2-dev:i386

configure: liblcms2 32-bit development files not found, Color Management won't be supported.

$ sudo apt install liblcms2-dev:i386

configure: OSS sound system found but too old (OSSv4 needed), OSS won't be supported.

$ sudo apt install oss4-dev

configure: libudev 32-bit development files not found, plug and play won't be supported.

$ sudo apt install libudev-dev:i386

configure: libcapi20 32-bit development files not found, ISDN won't be supported.

$ sudo apt install libcapi20-dev:i386

configure: libcups 32-bit development files not found, CUPS won't be supported.

$ sudo apt install libcups2-dev:i386 

configure: fontconfig 32-bit development files not found, fontconfig won't be supported.

$ sudo apt install libfontconfig1-dev:i386

configure: libgsm 32-bit development files not found, gsm 06.10 codec won't be supported.

$ sudo apt install libgsm1-dev:i386

configure: libtiff 32-bit development files not found, TIFF won't be supported.

$ sudo apt install libtiff5-dev:i386

configure: libmpg123 32-bit development files not found (or too old), mp3 codec won't be supported.

$ sudo apt install libmpg123-dev:i386

configure: libopenal 32-bit development files not found (or too old), OpenAL won't be supported

$ sudo apt install libopenal-dev:i386

configure: libldap (OpenLDAP) 32-bit development files not found, LDAP won't be supported.

$ sudo apt install libldap2-dev:i386

configure: WARNING: libxml2 32-bit development files not found (or too old), XML won't be supported.

$ sudo apt install libxml2-dev:i386

configure: WARNING: libxslt 32-bit development files not found, xslt won't be supported.

$ sudo apt install libxslt1-dev:i386

configure: WARNING: libgnutls 32-bit development files not found, no schannel support.

$ sudo apt install libgnutls28-dev:i386

ここまでのメッセージは消せたのだが、以下のメッセージは消えなかった・・・

configure: libpulse 32-bit development files not found or too old, Pulse won't be supported.

configure: gstreamer-1.0 base plugins 32-bit development files not found, gstreamer support disabled

configure: libdbus 32-bit development files not found, no dynamic device support.

誰か教えてください・・・

$ ./configure
$ make
$ sudo make install
$ wine --version
wine-2.0-rc5