Hello,

I am having some problems to link my program with the SSL library
libssl.a and libcrypto.a.
I have a small program called sslexample.c that just opens a simple
SSL connection. However, if I compile the program to use the shared
libraries libssl.so and libcrypto.so then everything works fine.

The following links and compiles correctly:
=========================================================
gcc -lssl -lcrypto sslexample.c -o sslexample
or
gcc /usr/lib/libssl.so /usr/lib/libcrypto.so sslexample.c -o sslexample
=========================================================

However, if I try to compile statically I get problems. There are many
undefined symbols when we reach the link stage:
=========================================================
gcc /usr/lib/libssl.a /usr/lib/libcrypto.a sslexample.c -o sslexample

/tmp/ccAiuJ1H.o(.text+0xe7): In function `main':
: undefined reference to `ERR_load_BIO_strings'
/tmp/ccAiuJ1H.o(.text+0xec): In function `main':
: undefined reference to `SSL_load_error_strings'
/tmp/ccAiuJ1H.o(.text+0xf1): In function `main':
: undefined reference to `OPENSSL_add_all_algorithms_noconf'
/tmp/ccAiuJ1H.o(.text+0xfc): In function `main':
: undefined reference to `SSLv23_client_method'
/tmp/ccAiuJ1H.o(.text+0x105): In function `main':
: undefined reference to `SSL_CTX_new'
/tmp/ccAiuJ1H.o(.text+0x11d): In function `main':
: undefined reference to `SSL_CTX_load_verify_locations'
/tmp/ccAiuJ1H.o(.text+0x148): In function `main':
: undefined reference to `ERR_print_errors_fp'
/tmp/ccAiuJ1H.o(.text+0x156): In function `main':
: undefined reference to `SSL_CTX_free'
/tmp/ccAiuJ1H.o(.text+0x17b): In function `main':
: undefined reference to `SSL_new'
/tmp/ccAiuJ1H.o(.text+0x18e): In function `main':
: undefined reference to `BIO_new_socket'
/tmp/ccAiuJ1H.o(.text+0x1a5): In function `main':
: undefined reference to `SSL_set_bio'
/tmp/ccAiuJ1H.o(.text+0x1b3): In function `main':
: undefined reference to `SSL_connect'
/tmp/ccAiuJ1H.o(.text+0x1d5): In function `main':
: undefined reference to `SSL_get_verify_result'
/tmp/ccAiuJ1H.o(.text+0x1ea): In function `main':
: undefined reference to `SSL_get_verify_result'
/tmp/ccAiuJ1H.o(.text+0x20c): In function `main':
: undefined reference to `BIO_free_all'
/tmp/ccAiuJ1H.o(.text+0x21a): In function `main':
: undefined reference to `SSL_CTX_free'
/tmp/ccAiuJ1H.o(.text+0x249): In function `main':
: undefined reference to `SSL_write'
/tmp/ccAiuJ1H.o(.text+0x263): In function `main':
: undefined reference to `SSL_read'
/tmp/ccAiuJ1H.o(.text+0x2a1): In function `main':
: undefined reference to `BIO_free_all'
/tmp/ccAiuJ1H.o(.text+0x2af): In function `main':
: undefined reference to `SSL_CTX_free'
collect2: ld returned 1 exit status
=========================================================

I am using a linux machine running fedora core 3. The version of
openssl that comes with fedora core 3 is openssl-0.9.7a. But I have
also downloaded and installed the latest openssl-0.9.7g and I get the
same problem when I try to link statically.

My gcc version is 3.4.3
========================================================================
gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3)
========================================================================

There must probably be something wrong with the way I link programs.
Which means I do not know how to link statically :) ... does anyone
know the problem that I am having ?

Thanks
Richard
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to