RubyとQML/Qt Quickでデスクトップ用GUIアプリを書けるgem「ruby-qml」を作った - Qiita
をインストールしようとして、いきなり失敗したので、その備忘録。
環境
MacBook Pro with Retina 13" (Late 2013) 2.4 GHz Intel Core i5
Qt インストーラのダウンロード
Download Qt | Qt Project
から
Qt Online Installer for MacOS (9.4 MB)(インストーラのバージョンは1.6.0)
をダウンロード。
Qt インストール
詳細を記録し落としたのですが、インストール先は標準にしていたと思います。
現在のインストール先は ~/Qt
です。
Qt 5.3.1 (Clang 5.0 (Apple), 64bit) の Qt Creator がインストールされました。
2014/7/1追記:ruby-qml-0.0.5 でインストールに成功
上記手順で Qt をインストールしたあとに
ruby-qml by seanchas116 に記載されているように
$ brew install pkg-config libffi
$ gem install qml -- --with-libffi-dir=$(brew --prefix libffi) --with-qt-dir=$HOME/Qt/5.3/clang_64
を実行することでインストールが出来ました(--with-qt-dir=$HOME/Qt/5.3/clang_64
の部分は Qt インストール環境に合わせてください)。
Homebrew で Qt もインストールする場合には
$ brew install pkg-config libffi qt5
$ gem install qml -- --with-libffi-dir=$(brew --prefix libffi) --with-qt-dir=$(brew --prefix qt5)
で行えるそうです。
以下は ruby-qml-0.0.4 での履歴です
念のために残しておきます。
ruby-qml gem をインストール(失敗1)
$ gem install qml
Fetching: qml-0.0.4.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing qml:
ERROR: Failed to build gem native extension.
/Users/riocampos/.rbenv/versions/1.9.3-p484/bin/ruby extconf.rb
checking for pkg-config... yes
checking for qmake... no
checking for moc... no
qmake executable not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/riocampos/.rbenv/versions/1.9.3-p484/bin/ruby
--with-pkg-config
--without-pkg-config
--with-qt-dir
--without-qt-dir
--with-libffi-dir
--without-libffi-dir
Gem files will remain installed in /Users/riocampos/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/qml-0.0.4 for inspection.
Results logged to /Users/riocampos/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/qml-0.0.4/ext/qml/gem_make.out
native extensionsのビルドで失敗したと思われます。 qmake
が見付からない、らしい。
qmake はどこだ
Qtのインストール先が ~/Qt
なので qmake
は ~/Qt/5.3/clang_64/bin
にありました。しかし PATH が通っていません。通しましょう。
# Qt5.3
export PATH="$HOME/Qt/5.3/clang_64/bin:$PATH"
ruby-qml gem をインストール(失敗2)
$ gem install qml
Building native extensions. This could take a while...
ERROR: Error installing qml:
ERROR: Failed to build gem native extension.
/Users/riocampos/.rbenv/versions/1.9.3-p484/bin/ruby extconf.rb
checking for pkg-config... yes
checking for qmake... yes
checking for moc... yes
building plugins...
:(中略)
Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Core' found
Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Core' found
Package Qt5Gui was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Gui.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Gui' found
Package Qt5Gui was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Gui.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Gui' found
Package Qt5Widgets was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Widgets.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Widgets' found
Package Qt5Widgets was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Widgets.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Widgets' found
Package Qt5Qml was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Qml.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Qml' found
Package Qt5Qml was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Qml.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Qml' found
Package Qt5Quick was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Quick.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Quick' found
Package Qt5Quick was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Quick.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Quick' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Core' found
Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Core' found
checking for QObject... no
header not found: QObject
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/riocampos/.rbenv/versions/1.9.3-p484/bin/ruby
--with-pkg-config
--without-pkg-config
--with-qt-dir
--without-qt-dir
--with-libffi-dir
--without-libffi-dir
--enable-debug
--disable-debug
Gem files will remain installed in /Users/riocampos/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/qml-0.0.4 for inspection.
Results logged to /Users/riocampos/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/qml-0.0.4/ext/qml/gem_make.out
PKG_CONFIG_PATH
に Qt5Core.pc
などのあるディレクトリを指定しろということですね。
Qt5Core.pc とかはどこだ
~/Qt/5.3/clang_64/lib/pkgconfig
にあります(が、全てでは無かったですorz)。
ので
export PKG_CONFIG_PATH="$HOME/Qt/5.3/clang_64/lib/pkgconfig"
として場所を教えましょう。
ruby-qml gem をインストール(失敗3)
エラーログの要点のみを。
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
checking for QObject... no
header not found: QObject
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
libffi はどこよ
入ってませんでした。Homebrew でインストールできます。
$ brew install libffi
Warning: libffi-3.0.13 already installed
ありゃ。
$ brew info libffi
libffi: stable 3.0.13 (bottled), HEAD
http://sourceware.org/libffi/
This formula is keg-only.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
Some formulae require a newer version of libffi.
/usr/local/Cellar/libffi/3.0.13 (13 files, 388K)
Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/libffi.rb
Keg-only なので動いてませんね。動かしましょう。
brew link libffi --force
Linking /usr/local/Cellar/libffi/3.0.13... 9 symlinks created
ruby-qml gem をインストール(失敗4)
残ったエラーはこれだけ。
checking for QObject... no
header not found: QObject
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
もう分からんですorz
ヘッダファイル ~/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/Headers/qobject.h
のディレクトリを訊ねているのかと思って
export PKG_CONFIG_PATH="$HOME/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/Headers:$HOME/Qt/5.3/clang_64/lib/pkgconfig"
を指定したけれども同じエラーが返ってきた。
エラーログ ~/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/qml-0.0.4/ext/qml/mkmf.log
は
qml-0.0.4 gem install error log
に置きました。