static linking libssl and libcrypto

Floodeenjr, Thomas thomas_floodeenjr at
Mon Nov 4 13:01:30 UTC 2019

To check if you are linked statically or dynamically, what does ldd tell you? (ldd Your library should not have a dependency on or if you are linked statically.


From: openssl-users [mailto:openssl-users-bounces at] On Behalf Of Aijaz Baig
Sent: Sunday, November 3, 2019 11:30 PM
To: openssl-users at
Subject: static linking libssl and libcrypto

I am trying to build a shared library that internally links openssl and crypto libraries statically so I can use it in a production environment. To that end I am using the following Makefile




CFLAGS= -Wall -g -O -fPIC

RM= rm -f

.PHONY: all clean

src=$(wildcard *Generic/*.c *Linux/*.c)

$(info source=$(src))

#we use the custom compiled openssl version

#and NOT the one available on the system



INC+=$(foreach d,$(incdir),-I$d)

$(info includes=$(INC))


#LIB=-llibssl -llibcrypto

LIB+=-lssl -lcrypto

$(info links=$(LIB))





    $(RM) *.o *.so

    $(shell find $(APPBASE) -type f -iname "*.o" -exec rm -rf {} \;)


    ${CC} -static ${CFLAGS} $(INC) -c $< $(LIB) -o $@ $(obj)

    $(LINK.c) -shared $^ -o $@
As mentioned here (, I've changed the linker flags to:
-lcrypto -lz -ldl -static-libgcc

but it doesn't seem to change the size of the generated so file. On checking for references to SSL in this so file, I see there are a total of 87 entries

nm | grep -i "ssl" | wc -l

whereas listing only the global symbols from libssl.a tells me it has 1113 globally defined symbols.
nm -g ../OpenSSL-1.0.2p-installation/lib/libssl.a | grep -i "ssl" | wc -l

I do not know if libSSL got indeed linked statically or not. Could someone please shed some light on it?


Best Regards,
Aijaz Baig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the openssl-users mailing list