Thanks.  I had eventually succeeded by fixing my list of object files.





-----Original Message-----
From: Albrecht Schlosser <ml-...@go4more.de>
To: openssl-users <openssl-users@openssl.org>
Sent: Tue, Jul 19, 2011 12:24 pm
Subject: Re: Trying to Link Statically to Libcrypto


  On 19.07.2011 16:49, brandon...@aol.com wrote:
 *Okay, it is acting like my /usr/lib/libssl.a is of no value.  First, 
 just for comparison, attempting to link with no reference to libssl at 
 all:*
Today at 14:23 you wrote "Thanks for the lesson.  Highly informative.",
ut now you're still doing it wrong :-(
Note that this will be my last message to this thread, since learning
inking order is OT here.
>
 [root@linux Release]# g++  -o"<My exe name>" <my object file list> 
 /usr/lib/libcrypto.a /usr/lib/libldap.a /usr/lib/libxml2.a 
 /usr/lib/liblber.a -lz -ldl -lm -lsasl2 2>&1
Okay, libcrypto is *before* libldap, and libssl is missing (you wrote that).
nipping unused error messages...
> /usr/lib/libldap.a(tls_o.o): In function `tlso_sb_close':
 (.text+0xa6): undefined reference to `SSL_shutdown'
SSL_shutdown is still missing, because libssl is missing.
>
 *Now, including /usr/lib/libssl.a at the end of the list of object file:*

 [root@linux Release]# g++  -o"<My exe name>" <my object file list>   
 /usr/lib/libcrypto.a /usr/lib/libldap.a /usr/lib/libxml2.a 
 /usr/lib/liblber.a /usr/lib/libssl.a -lz -ldl -lm -lsasl2 2>&1
> /usr/lib/libldap.a(tls_o.o): In function `tlso_session_chkhost':
 (.text+0x8a6): undefined reference to `X509_get_ext_by_NID'
X509* functions are in libcrypto - you should have found
hat out meanwhile. They can't be found by the linker because
ibcrypto is *before* libldap!
Furthermore, now that you added libssl, SSL_shutdown
is* found by the linker (not in the error list anymore).

 *Now, including /usr/lib/libssl.a at the beginning of the list of 
 object file:*
Another useless try...
>
 *Now, giving up and allowing it to choose the so version, suddenly 
 everything works.  There are two warnings, but no errors.*

 [root@linux Release]# g++  -o"<My exe name>" <my object file list>  
 /usr/lib/libcrypto.a /usr/lib/libldap.a /usr/lib/libxml2.a 
 /usr/lib/liblber.a -lz -ldl -lm -lssl -lsasl2 2>&1
 /usr/lib/libldap.a(os-ip.o): In function `ldap_int_poll':
 (.text+0x9c4): warning: `sys_errlist' is deprecated; use `strerror' or 
 `strerror_r' instead
 /usr/lib/libldap.a(os-ip.o): In function `ldap_int_poll':
 (.text+0x9ba): warning: `sys_nerr' is deprecated; use `strerror' or 
 `strerror_r' instead
 [root@linux Release]#

 Anyone have an idea why the static version of the library doesn't seem 
 to work?
Because if you link with the shared libraries, the linker adds the entire
ibraries (symbols) to its internal list of known symbols, and thus it
an resolve all references. Check the order again, and then you'll be
ble to link statically as well.
Hint: ldap - ssl - crypto - others...
-- 
egards
lbrecht
______________________________________________________________________
penSSL Project                                 http://www.openssl.org
ser Support Mailing List                    openssl-users@openssl.org
utomated List Manager                           majord...@openssl.org

Reply via email to