problem about static link libssl.a libcrypto.a to my application(linux platform)

View: New views
2 Messages — Rating Filter:   Alert me  

problem about static link libssl.a libcrypto.a to my application(linux platform)

by jj Zhu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    It goes well when dynamic linking, using command like this:
      gcc -lssl error.o wrapsock.o wrapunix.o driverUtility.o driver.o -o driver
then I want to link openssl lib statically so I do not need to install openssl when  I run my application on another linux platform,but after I change the command into this:
      gcc -static /usr/lib/libssl.a /usr/lib/libcrypto.a error.o wrapsock.o  wrapunix.o driverUtility.o driver.o -o driver
      I get these compile errors:
driver.o: In function `logout':
driver.c:(.text+0x16e): undefined reference to `SSL_library_init'
driver.c:(.text+0x173): undefined reference to `SSL_load_error_strings'
driver.c:(.text+0x178): undefined reference to `SSLv23_client_method'
driver.c:(.text+0x180): undefined reference to `SSL_CTX_new'
driver.c:(.text+0x1b8): undefined reference to `SSL_new'
driver.c:(.text+0x1fa): undefined reference to `SSL_set_fd'
driver.c:(.text+0x232): undefined reference to `SSL_connect'
driver.c:(.text+0x329): undefined reference to `SSL_write'
driver.c:(.text+0x378): undefined reference to `SSL_shutdown'
driver.c:(.text+0x38c): undefined reference to `SSL_free'
driver.c:(.text+0x39a): undefined reference to `SSL_CTX_free'
       I checked and found that there does exist /usr/lib/libssl.a /usr/lib/libcrypto.a in my system, I don't konw why? Is there probably something wrong with the /usr/lib/libssl.a /usr/lib/libcrypto.a? Can someone tell me how to statically link openssl lib to my application?
 2009-11-04

zhujj


Re: problem about static link libssl.a libcrypto.a to my application(linux platform)

by Mike Frysinger-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 08:24, jj Zhu wrote:
>       gcc -static /usr/lib/libssl.a /usr/lib/libcrypto.a error.o wrapsock.o
> wrapunix.o driverUtility.o driver.o -o driver
>       I get these compile errors:
> driver.o: In function `logout':
> driver.c:(.text+0x16e): undefined reference to `SSL_library_init'

your link order is wrong.  the libraries have to come after all your
source files.

you also shouldnt use full paths.  use the normal -lssl style -- the
-static flag will select the right library.
-mike
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@...
Automated List Manager                           majordomo@...