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.