Ruby eventmachine编译错误

时间:2011-11-05 17:24:13

标签: ruby g++ debian rvm eventmachine

eventmachine 0.12.10上编译ruby 1.9.2-p290时,我收到以下错误输出:

g++ -shared -o rubyeventmachine.so binder.o cmain.o cplusplus.o ed.o em.o emwin.o epoll.o files.o kb.o page.o pipe.o rubymain.o sigs.o ssl.o -L. -L/home/git/.rvm/rubies/ruby-1.9.2-p290/lib -Wl,-R/home/git/.rvm/rubies/ruby-1.9.2-p290/lib -L.  -rdynamic -Wl,-export-dynamic    -Wl,-R -Wl,/home/git/.rvm/rubies/ruby-1.9.2-p290/lib -L/home/git/.rvm/rubies/ruby-1.9.2-p290/lib -lruby  -lssl -lcrypto   -lpthread -lrt -ldl -lcrypt -lm   -lc
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(functexcept.o): relocation         R_X86_64_32 against `std::bad_typeid::~bad_typeid()' can not be used when making a shared     object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

这是在运行debian squeeze的linux机器上完成的。

有什么建议吗?提前谢谢!

4 个答案:

答案 0 :(得分:2)

我有一个类似的问题试图在标准的debian挤压装置上构建mosh-1.2.2。以下对我有用:

# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# rm libstdc++.so
# ln -s ../../../x86_64-linux-gnu/libstdc++.so.6 libstdc++.so

为了更详细地解释,现有的符号链接指向一个不存在的文件:

# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# ls -l libstdc++.so
..
lrwxrwxrwx 1 root root      23 May  3  2011 libstdc++.so -> ../../../libstdc++.so.6
..

我找到了正确的文件位置

# dpkg -S 'libstdc'
..
libstdc++6: /usr/lib/x86_64-linux-gnu/libstdc++.so.6
..

然后按照第一个代码段中的描述修复了符号链接。

我在编译期间遇到的错误是:

make[3]: *** [mosh-client] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_typeid::~bad_typeid()' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value

不知道这个特殊的debian挤压服务器是如何破坏的。我一直在编译其他挤压系统,没有任何问题。

答案 1 :(得分:0)

您的gcc安装不好。

特别是libstdc++.a中有/usr/lib/gcc/x86_64-linux-gnu/4.4.5/,但(显然)不是libstdc++.so

libstdc++.a中的代码未使用-fPIC标记构建,因此您无法将该代码链接到共享库。

答案 2 :(得分:0)

尝试使用ree 1.8.7-2012.02rvm安装therubyracer 0.9.9时出现同样的问题。您编写的最后一条评论使我能够正确修复它,我只是使用下一个命令将g ++更新为测试版本:

sudo apt-get install -t wheezy g++

有关使用不同版本的软件包保存debian系统的更多信息,请参阅debian doc How to keep a mixed system

答案 3 :(得分:0)

升级到 ruby​​ 2.2.3 为我解决了这个问题

$ gcc -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3)
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
相关问题