I tried to link libssl statically under Ubuntu 13.04. But it depends on libz and there are unresolved symbols when libssl.a or librypto.a are linked.
There are two options what libz to use- "system" and "bundled". In the case of "bundled" there are no unresolved symbols in "bundled" version:
/usr/lib/ccache/c++ -fPIC -Wall -Wno-unused-parameter -O3 -DNDEBUG -DDBUG_OFF -DMY_PTHREAD_FASTMUTEX=1 CMakeFiles/comp_err.dir/comp_err.c.o -o comp_err -lpthread ../mysys/libmysys.a ../mysys_ssl/libmysys_ssl.a ../mysys/libmysys.a ../dbug/libdbug.a ../mysys/libmysys.a ../dbug/libdbug.a -lm ../strings/libstrings.a ../zlib/libzlib.a -lpthread -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -ldl
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x284): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x342): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x411): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x5d7): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x659): undefined reference to `deflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x893): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x90d): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x97c): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xa6f): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xaec): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xb7e): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
But when system libz is used the following error take place:
/usr/lib/ccache/c++ -fPIC -fPIC -Wall -Wno-unused-parameter -O3 -DNDEBUG -DDBUG_OFF -DMY_PTHREAD_FASTMUTEX=1 -Wl,--no-undefined -Wl,--version-script=libmysql.ver -shared -Wl,-soname,libmysqlclient.so.18 -o libmysqlclient.so.18.0.0 CMakeFiles/libmysql.dir/libmysql_exports_file.cc.o -lpthread libclientlib.a ../dbug/libdbug.a ../strings/libstrings.a ../vio/libvio.a ../mysys/libmysys.a ../mysys_ssl/libmysys_ssl.a -lz -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -ldl -ldl ../dbug/libdbug.a ../mysys/libmysys.a ../dbug/libdbug.a ../mysys/libmysys.a -lm ../strings/libstrings.a -lpthread -lz
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libssl.a(t1_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
I tried to link libssl statically under Ubuntu 13.04. But it depends on libz and there are unresolved symbols when libssl.a or librypto.a are linked.
There are two options what libz to use- "system" and "bundled". In the case of "bundled" there are no unresolved symbols in "bundled" version:
/usr/lib/ccache/c++ -fPIC -Wall -Wno-unused- parameter -O3 -DNDEBUG -DDBUG_OFF -DMY_PTHREAD_ FASTMUTEX= 1 CMakeFiles/ comp_err. dir/comp_ err.c.o -o comp_err -lpthread ../mysys/libmysys.a ../mysys_ ssl/libmysys_ ssl.a ../mysys/libmysys.a ../dbug/libdbug.a ../mysys/libmysys.a ../dbug/libdbug.a -lm ../strings/ libstrings. a ../zlib/libzlib.a -lpthread -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -ldl gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_free': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_free': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_ctrl': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_ctrl': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `zlib_stateful_ expand_ block': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `zlib_stateful_ compress_ block': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `zlib_stateful_ finish' : gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `zlib_stateful_ finish' : gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `zlib_stateful_ init': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `zlib_stateful_ init': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_read': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_read': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_read': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_write': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_write': gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libcrypto. a(c_zlib. o): In function `bio_zlib_write':
/usr/lib/
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/
(.text+0x284): undefined reference to `deflate'
/usr/lib/
(.text+0x342): undefined reference to `zError'
/usr/lib/
(.text+0x411): undefined reference to `inflate'
/usr/lib/
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/
(.text+0x5d7): undefined reference to `inflateInit_'
/usr/lib/
(.text+0x659): undefined reference to `deflateInit_'
/usr/lib/
(.text+0x893): undefined reference to `inflate'
/usr/lib/
(.text+0x90d): undefined reference to `zError'
/usr/lib/
(.text+0x97c): undefined reference to `inflateInit_'
/usr/lib/
(.text+0xa6f): undefined reference to `deflate'
/usr/lib/
(.text+0xaec): undefined reference to `zError'
/usr/lib/
(.text+0xb7e): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
But when system libz is used the following error take place:
/usr/lib/ccache/c++ -fPIC -fPIC -Wall -Wno-unused- parameter -O3 -DNDEBUG -DDBUG_OFF -DMY_PTHREAD_ FASTMUTEX= 1 -Wl,--no-undefined -Wl,--version- script= libmysql. ver -shared -Wl,-soname, libmysqlclient. so.18 -o libmysqlclient. so.18.0. 0 CMakeFiles/ libmysql. dir/libmysql_ exports_ file.cc. o -lpthread libclientlib.a ../dbug/libdbug.a ../strings/ libstrings. a ../vio/libvio.a ../mysys/libmysys.a ../mysys_ ssl/libmysys_ ssl.a -lz -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -ldl -ldl ../dbug/libdbug.a ../mysys/libmysys.a ../dbug/libdbug.a ../mysys/libmysys.a -lm ../strings/ libstrings. a -lpthread -lz gcc/x86_ 64-linux- gnu/4.7/ ../../. ./x86_64- linux-gnu/ libssl. a(t1_srvr. o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/lib/