ruby用fPIC编译

时间:2013-06-17 04:59:15

标签: ruby qt rbenv

我在Debian 7下通过rbenv使用ruby 1.9.3p392,我试图安装qtbindings gem,这样我就可以运行一个使用qt libs的旧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? 我也试过了宝石安装qtbindings - -fPIC'但得到了同样的错误。

1 个答案:

答案 0 :(得分:3)

尝试

#gem install qtbindings -- --with-cflags=\"-fPIC\"

来源: Is there any way to change gcc compilation options for a gem?

<强>编辑:

是的,再看看你的代码,我的错。问题在于安装的红宝石,而不是宝石。

查看this(上一篇文章)

尝试使用共享库重新安装ruby:

CONFIGURE_OPTS="--enable-shared" rbenv install 1.9.3-p392