开发者

OpenSSL error building Erlang OTP from source

开发者 https://www.devze.com 2023-03-18 08:14 出处:网络
Trying to build a completely self-contained OTP that can be moved around independently of libs installed on a system.

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 talkin开发者_运维知识库g Ubuntu 10.04. Any help greatly appreciated - thanks!


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:

$ tar zxvf openssl-0.x.tar.gz
$ cd openssl-x
$ sh config shared -fPIC
$ make
$ sudo make install


For ppc64le:

./configure --prefix=/home/huaxin/huaxin/toolsInstalled/ --build=ppc64le CFLAGS="-D_GNU_SOURCE -DOPENSSL_NO_EC=1"


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消