reducing size of shared library that uses crypto++

41 views
Skip to first unread message

amno...@gmail.com

unread,
Mar 26, 2007, 6:21:56 AM3/26/07
to Crypto++ Users
Hi,

I'm working on a shared library that uses some of the Crypto++
functionality, so it links with the statically linked version of Crypto
++. The problem is that on Linux the resulting object's size is 4M,
even though it doesn't use that much of Crypto++. I'm sure that not
all of the 4M is needed since I can compile the object as a
(functioning) executable and then its size is about 300K. Also, the
size of the same shared library compiled on Windows and linked to the
static library is about 300K.

The flags I use to compile crypto++ are:

CXXFLAGS = -O -ffunction-sections -fdata-sections
LDFLAGS += -Wl,--gc-sections

I compile my library like this: g++ -shared mylib.o libcryptopp.a

What flags should I pass to the compiler or the linker in order to
make a shared library that is statically linked to Crypto++ and has
minimal size?

Thanks
Amnon

Wei Dai

unread,
Mar 26, 2007, 6:54:45 AM3/26/07
to amno...@gmail.com, Crypto++ Users
Section 2.2 of this document may be of help:

http://people.redhat.com/drepper/dsohowto.pdf

Amnon Aaronsohn

unread,
Mar 28, 2007, 12:08:56 PM3/28/07
to Crypto++ Users
On Mar 26, 12:54 pm, "Wei Dai" <wei...@weidai.com> wrote:
> > What flags should I pass to the compiler or the linker in order to
> > make a shared library that is statically linked to Crypto++ and has
> > minimal size?
> Section 2.2 of this document may be of help:
> http://people.redhat.com/drepper/dsohowto.pdf

Thanks for the helpful link. Adding "-fvisibility=hidden -fvisibility-
inlines-hidden" to the compilation options of
both crypto++ and my library (making sure public symbols are exported)
did the trick.

Amnon

Reply all
Reply to author
Forward
0 new messages