On Mon December 19 2011, grarpamp wrote:
> I have a case that needs zlib statically in openssl.
> But I can't seem to make that. Only dynamic is made.
> 
> For testing I put zlib125 in its own <dir>.
> Then for openssl...
> 
> ./config
> --prefix=<path>
> --with-zlib-include=<dir>/include
> --with-zlib-lib=<dir>/lib
> shared
> zlib
> 
> make
> make install
> 
> This gives...
> 
> LD_LIBRARY_PATH=../zlib125/lib ldd bin/openssl
> bin/openssl:
>    libssl.so.1.0.0 => /.../openssl100e/lib/libssl.so.1.0.0 (0x28102000)
>    libcrypto.so.1.0.0 => /.../openssl100e/lib/libcrypto.so.1.0.0 (0x28151000)
> => libz.so.1 => ../zlib125/lib/libz.so.1 (0x282bd000)
>    libthr.so.3 => /lib/libthr.so.3 (0x282d3000)
>    libc.so.7 => /lib/libc.so.7 (0x282e8000)
> 
> As far as I understand things...
> 'zlib-dynamic' is to include zlib dynamically.
> 'zlib' is to include zlib statically.
> But as shown above, 'zlib' is not doing that.
> 
> So I think this is a bug, is that correct?
> If it is my configuration usage, how do I make zlib static?
>

I had to read this thread several times before I caught onto
the context of your question.

If I restate your question a bit for the more general case:

I have an application which should link statically against
one (or more) specific library(ies) and dynamically against
the rest of the external libraries...

Then the general case answer is:

You have to make two link(er) passes;
The first to produce a "partial link" output that is your
application linked against the selected static library(ies);
The second to complete the linkage using the dynamic library(ies).

The general case answer when using a GCC/Binutils toolchain:

For many situations you can emulate multiple linker passes by using
the --start-group <archives> --end-group pair of option quotes.
From the gcc command line: -Wl,--start-group <archives> -Wl,--end-group

There is a short form of that option pair: -( archives )-

Where: "archives" may be a list of object files also.

So if Binutils linker (or GCC linker) command included only static library(ies)
within the group, then the linker would make repeated passes over that
group until no new undefined symbols where generated.
In this case, by statically linking in the specified archive(s).  ;-)

Your more specific question:

How to get the OpenSSL Makefile to recognize: zlib-static (or zlib as static)?

If using GCC/Binutils toolchain, then answering that one is a matter
of either reading the Makefile(s) or waiting for an author of the Makefile(s)
to take note of this thread and tell us.

The thing(s) to look for would be either a Makefile that produces more than
one linker run over the object files or that uses the grouping quotes (or both).

If using any other toolchain, I don't have the slightest clue.

Mike
> 
> Also, is 'enc -z' the standard zlib testing method?
> Why am I getting such a poor compression ratio?
> The hashes are md5 in place of wc.
> I did check that adding the final reverse '-d' pipe does yield 1MiB
> zeros.
> 
> dd if=/dev/zero bs=1m count=1 | LD_LIBRARY_PATH=../zlib125/lib
> bin/openssl enc -aes128 -a -k 0 -S 0 -e | wc -c
> 1419990 f8a4638a913dedd984f987767a24796c
> dd if=/dev/zero bs=1m count=1 | LD_LIBRARY_PATH=../zlib125/lib
> bin/openssl enc -aes128 -a -k 0 -S 0 -e -z | wc -c
> 1080369 a48155fc72d937c4cfdc609e18b470ac
> dd if=/dev/zero bs=1m count=1 | LD_LIBRARY_PATH=../zlib125/lib
> bin/openssl zlib -aes128 -a -k 0 -S 0 -e | wc -c
> 1080369 a48155fc72d937c4cfdc609e18b470ac
> dd if=/dev/zero bs=1m count=1 | LD_LIBRARY_PATH=../zlib125/lib
> bin/openssl zlib -e | wc -c
> 1039 cfd12ca5dd18c8cd22cc34bb757c8b9f
> dd if=/dev/zero bs=1m count=1 | gzip -n |
> LD_LIBRARY_PATH=../zlib125/lib bin/openssl enc -aes128 -a -k 0 -S 0 -e
> | wc -c
> 1455 08d52ad99d2f6edf344ef735ad62150c
> 
> 
> There are some documentation bugs...
> enc.1: -z should read: 'was compiled'.
> 'openssl zlib' does not appear to be documented.
> 
> Thanks.
> 
> 
> FreeBSD RELENG_8 i386
> OpenSSL 1.0.0e 6 Sep 2011
> platform: BSD-x86-elf
> options: bn(64,32) rc4(4x,int) des(ptr,risc1,16,long) idea(int)
>  blowfish(idx)
> compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -pthread
>  -D_THREAD_SAFE -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack
>  -DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -Wall
>  -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_BN_ASM_MONT -DSHA1_ASM
>  -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
> 
> 


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to