从源代码构建 Erlang OTP 时出现 OpenSSL 错误
尝试构建一个完全独立的 OTP,可以独立于系统上安装的库进行移动。
从源代码构建 OpenSSL 1.0.0d,如下所示:
./config --prefix=<open-ssl-dir>
make
make install
然后 OTP R14B03:
./configure --prefix=<erlang-dir> --with-ssl=<open-ssl-dir> --without-termcap
Make of Erlang 然后失败,如下所示:
relocation R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a shared object; recompile with -fPIC
我们正在谈论 Ubuntu 10.04。非常感谢任何帮助 - 谢谢!
Trying to build a completely self-contained OTP that can be moved around independently of libs installed on a system.
Build OpenSSL 1.0.0d from source as follows:
./config --prefix=<open-ssl-dir>
make
make install
Then OTP R14B03:
./configure --prefix=<erlang-dir> --with-ssl=<open-ssl-dir> --without-termcap
Make of Erlang then fails as follows:
relocation R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a shared object; recompile with -fPIC
We're talking Ubuntu 10.04. Any help greatly appreciated - thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“创建共享对象时不能使用;使用 -fPIC 重新编译”意味着 SSL 不是使用位置无关代码标志构建的。这是将其构建为动态共享对象 (DSO) 所必需的。这可能是 Erlang 构建过程所需要的。示例构建:
The "can not be used when making a shared object; recompile with -fPIC" would mean SSL is not build with the Position Independent Code flag. This is needed for building it as a Dynamic Shared Object (DSO). This is probably needed by Erlang build process. Example build:
对于 ppc64le:
For ppc64le:
我建议您在具有 sudo 权限的虚拟机上进行构建。然后使用 --prefix=/usr 构建 OpenSSL 等库,以便 make install 将它们放入常用的系统库中。
然后使用 -rpath 构建您的工具,在本例中为 Erlang。然后使用 ldd 查找 Erlang 和任何端口(C 扩展)的所有库依赖项,并将它们复制到 Erlangs lib 目录中。使用 readelf -d 检查所有二进制文件和库,以确保 RPATH 根据需要设置为 $ORIGIN 或 $ORIGIN/../lib 。如果链接过程不太正确(或者您复制了系统库的辅助依赖项),请使用 patchelf 来修复这些问题。
然后使用 patchelf 将二进制文件(而不是库)的解释器设置为指向 Erlang 的 lib 目录中的 ld-linux.so.2 。然后使用
strace -e open erl ... 运行测试套件,以确保您的构建不会打开 /lib 或 /usr/lib 中的任何内容。
此时将其打包,它将在任何 Linux 上运行。
看到这个问题在 Ubuntu 中编译 Python 2.6.6 并需要外部包 wxPython、setuptools 等...,了解有关我如何在此构建 Python 的更多详细信息 时尚。
I suggest that you build on a VM where you have sudo permissions. Then build libraries like OpenSSL using --prefix=/usr so that make install puts them in the usual system library.
Then build your tool, in this case Erlang, using -rpath. Then use
ldd
to find all library dependencies for Erlang and any ports (C extensions) and copy those into Erlangs lib directory. Check all binaries and libraries with readelf -d to make sure that RPATH is set to $ORIGIN or $ORIGIN/../lib as needed. Use patchelf to fix these things if the linking process is not quite right (or you copied in secondary dependencies of system libraries).Then use patchelf to set the interpreter for your binaries (not libraries) to point to ld-linux.so.2 in Erlang's lib directory. And then run a test suite using
strace -e open erl ...
to make sure that your build is not opening anything in /lib or /usr/lib.At this point tar it up and it will run on any Linux.
See this question Compiling Python 2.6.6 and need for external packages wxPython, setuptools, etc... in Ubuntu for far more detail on how I built Python in this fashion.