I am compiling libssh2 version 1.4.2 on a Solaris 10 machine.
It gets most of the way through the compilation, then I get this:
libtool: link: gcc -shared -fPIC -DPIC -Wl,-z -Wl,text -Wl,-M -Wl,.libs/libssh2.so.1.0.1.exp -Wl,-h -Wl,libssh2.so.1 -o .libs/libssh2.so.1.0.1 .libs/channel.o .libs/comp.o .libs/crypt.o .libs/hostkey.o .libs/kex.o .libs/mac.o .libs/misc.o .libs/packet.o .libs/publickey.o .libs/scp.o .libs/session.o .libs/sftp.o .libs/userauth.o .libs/transport.o .libs/version.o .libs/knownhost.o .libs/agent.o .libs/openssl.o .libs/libgcrypt.o .libs/pem.o .libs/keepalive.o .libs/global.o -L/export/home/ixbuild/local//lib -lssl -lcrypto -lz -lnsl -lsocket -lc -O2
Text relocation remains referenced
against symbol offset in file
<unknown> 0x10 /export/home/ixbuild/local//lib/libcrypto.a(dsa_asn1.o)
<unknown> 0x24 /export/home/ixbuild/local//lib/libcrypto.a(dsa_asn1.o)
CBIGNUM_it 0x28 /export/home/ixbuild/local//lib/libcrypto.a(dsa_asn1.o)
<unknown> 0x38 /export/home/ixbuild/local//lib/libcrypto.a(dsa_asn1.o)
CBIGNUM_it 0x3c /export/home/ixbuild/local//lib/libcrypto.a(dsa_asn1.o)
... many similar lines ...
ld: fatal: relocations remain against allocatable but non-writable sections
Googling around I found many references to this error in relation to compiling without -fPIC
, however this flag is already being used.
Strangely this worked fine a while back when I first set up this machine. At that time I was using libssh2-1.3.0.
UPDATE: @jww suggests that this is a duplicate of this answer, which states that the problem is missing -fPIC
flag. As already indicated in the question, I had already checked this and -fPIC
was being used. Check my answer below for the actual solution in my case.
In my case at least, this was due to trying to use gcc to compile the new version of libssh2, and link against an openssl library previously compiled using Solaris cc.
By adding a CC environment variable forcing configure
to use the Solaris cc command, like this, I could make it compile:
CC="/opt/solstudio12.2/bin/cc" ./configure --prefix=/export/home/ixbuild/local --disable-static
Looking at my notes from the previous installation I performed, I did not need to do this before, so either the configure script has somehow changed to prefer gcc if it is available, or perhaps the environment has changed (I am not completely sure if gcc was in the path when I built previously).