Summary:ASTERISK-20407: Asterisk compilation doesn't set rpath when --prefix is something other that /usr
Reporter:David M. Lee (dlee)Labels:
Date Opened:2012-09-11 16:13:50Date Closed:2013-01-18 15:11:20.000-0600
Versions:11.0.0-beta1 Frequency of
Environment:Attachments:( 0) ASTERISK-20407-fix-11.diff
( 1) ASTERISK-20407-fix-trunk.diff
Description:When Asterisk is compiled with {{--prefix}} set to something other than {{/usr}}, it fails to startup on Linux.

$ ./configure --prefix=/opt/asterisk
$ make all install
$ /opt/asterisk/sbin/asterisk
/opt/asterisk/sbin/asterisk: error while loading shared libraries: libasteriskssl.so.1: cannot open shared object file: No such file or directory

This is because the Asterisk build scripts do not to set the {{-rpath}} [linker option|http://linux.die.net/man/1/ld], which would allow the {{asterisk}} executable to automagically find the {{libasteriskssl.so}} shared object. This wasn't a problem before Asterisk 11, because there were no non-system shared objects for Asterisk to link to at startup.

h3. Workarounds

# Specify the linker flag to configure
$ LDFLAGS="-Wl,-rpath,/opt/asterisk/lib" ./configure --prefix=/opt/asterisk
# Specify {{LD_LIBRARY_PATH}} when launching
$ export LD_LIBRARY_PATH=/opt/asterisk/lib # DYLD_LIBRARY_PATH on BSD's and OS X
$ /opt/asterisk/sbin/asterisk
# Use [{{chrpath}}|http://linux.die.net/man/1/chrpath] to add rpath to the exe after the fact.
$ chrpath -r /opt/asterisk/lib /opt/asterisk/sbin/asterisk
# Disable the Asterisk SSL wrapper
$ ./configure --prefix=/opt/asterisk --disable-asteriskssl
Comments:By: David M. Lee (dlee) 2012-09-12 08:19:50.163-0500

Comma is more portable than equals. Whatever...

By: David M. Lee (dlee) 2012-09-12 08:53:53.686-0500

More workarounds

By: David M. Lee (dlee) 2012-09-26 12:39:56.650-0500

Patch for 11.

By: David M. Lee (dlee) 2012-09-26 12:40:13.783-0500

Patch for trunk.

By: vladimir shmagin (shmagin) 2012-11-27 06:33:30.416-0600

I have the same problem with default installation in Centos 6.3.
{noformat}[root@localhost asterisk-11.0.1]# whereis libasteriskssl.so
libasteriskssl: /usr/lib/libasteriskssl.so
[root@localhost asterisk-11.0.1]# /usr/sbin/asterisk
/usr/sbin/asterisk: error while loading shared libraries: libasteriskssl.so.1: cannot open shared object file: No such file or directory{noformat}
What do you recommend to use ??Workaround?? or ??patch?? ?

By: David M. Lee (dlee) 2012-11-27 09:20:53.379-0600

@vladimir - You are probably installing a 64-bit lib in the 32-bit {{/usr/lib}}. The right answer would be to configure using {{./configure --libdir=/usr/lib64}}.

By: Ray Seals (packetman) 2012-12-12 21:18:16.465-0600

@David M. Lee your suggestion regarding 64bit lib is correct in my case.  This was the cleanest solution.