我在 Debian 7 下通过 rbenv 使用 ruby 1.9.3p392,我正在尝试安装 qtbindings gem,这样我就可以运行一个使用 qt 库的旧 ruby 应用程序。
这是我在输入“gem install qtbindings”时遇到的错误
make[3]: Entering directory `/usr/local/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/qtbindings-4.8.3.0/ext/build'
[ 82%] Building CXX object ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/Qt.o
[ 82%] Building CXX object ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/handlers.o
[ 83%] Building CXX object ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/marshall_types.o
Linking CXX shared library libqtruby4shared.so
/usr/bin/ld: /usr/local/rbenv/versions/1.9.3-p392/lib/libruby-static.a(array.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/rbenv/versions/1.9.3-p392/lib/libruby-static.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[3]: *** [ruby/qtruby/src/libqtruby4shared.so.2.0.0] Error 1
make[3]: Leaving directory `/usr/local/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/qtbindings-4.8.3.0/ext/build'
make[2]: *** [ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/all] Error 2
make[2]: Leaving directory `/usr/local/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/qtbindings-4.8.3.0/ext/build'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/qtbindings-4.8.3.0/ext/build'
make: *** [build] Error 2
Gem files will remain installed in /usr/local/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/qtbindings-4.8.3.0 for inspection.
Results logged to /usr/local/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/qtbindings-4.8.3.0/./gem_make.out
我已经安装了以下要求
sudo aptitude install cmake build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline5-dev libreadline6-dev libxml2-dev git-core subversion autoconf xorg-dev libgl1-mesa-dev libglu1-mesa-dev qtcreator
如何用 fPIC 编译 ruby?我也尝试过“gem install qtbindings -- -fPIC”,但遇到了同样的错误。