Bug #68277 innochecksum link fails with system zlib
Submitted: 5 Feb 2013 15:59 Modified: 1 Mar 2013 16:46
Reporter: Andrea Scarpino Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.6.10 OS:Linux
Assigned to: Tor Didriksen CPU Architecture:Any

[5 Feb 2013 15:59] Andrea Scarpino
Description:
Linking CXX executable innochecksum
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x284): undefined reference to `deflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x344): undefined reference to `zError'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x411): undefined reference to `inflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x5e1): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x671): undefined reference to `deflateInit_'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x8a3): undefined reference to `inflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x91f): undefined reference to `zError'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x990): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xacb): undefined reference to `deflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xb5f): undefined reference to `zError'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xbf1): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
make[2]: *** [extra/innochecksum] Error 1
make[1]: *** [extra/CMakeFiles/innochecksum.dir/all] Error 2
make: *** [all] Error 2

How to repeat:
Get the mysql 5.6.10 source tarball and try to build it.
Install zlib, then try to build mysql using WITH_ZLIB=system
[5 Feb 2013 16:45] MySQL Verification Team
Thank you for the bug report. I got the below error compiling message instead:

Linking CXX executable pfs_connect_attr-t
/usr/bin/ld: cannot find -lzlib
collect2: ld returned 1 exit status
make[2]: *** [storage/perfschema/unittest/pfs_connect_attr-t] Error 1
make[1]: *** [storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/all] Error 2
make: *** [all] Error 2
[miguel@CENTOS63 mysql-5.6.10]$
[6 Feb 2013 10:48] didier fabert
Same problem here. 

here is my configure line
cmake . -DBUILD_CONFIG=mysql_release '-DCOMPILATION_COMMENT=MySQL Community Server (GPL)' -DFEATURE_SET=community -DINSTALL_LAYOUT=RPM -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_INFODIR=share/info -DINSTALL_LIBDIR=lib/mysql -DINSTALL_MANDIR=share/man -DINSTALL_MYSQLSHAREDIR=share/mysql -DINSTALL_MYSQLTESTDIR=share/mysql-test -DINSTALL_PLUGINDIR=lib/mysql/plugin -DINSTALL_SBINDIR=libexec -DINSTALL_SCRIPTDIR=bin -DINSTALL_SQLBENCHDIR=share -DINSTALL_SUPPORTFILESDIR=share/mysql -DMYSQL_DATADIR=/var/lib/mysql -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DENABLED_LOCAL_INFILE=ON -DENABLE_DTRACE=ON -DWITH_EMBEDDED_SERVER=ON -DWITH_READLINE=ON -DWITH_SSL=system -DWITH_ZLIB=system
[7 Feb 2013 8:45] didier fabert
Patch: wrong zlib library name ( libz not libzlib )

Attachment: mysql-perfschema-zlib.patch (text/x-patch), 792 bytes.

[8 Feb 2013 12:35] Tor Didriksen
I can reproduce the pfs_connect_attr-t problem, an easy fix.

Andrea Scarpino:
I assume you did -DWITH_SSL=system in addition to -DWITH_ZLIB=system
It seems you have /usr/lib/libcrypto.a rather than the corresponding
shared library. On my machine, I get:
$ldd /usr/lib/libcrypto.so.10 
        linux-gate.so.1 =>  (0xf76e9000)
        libdl.so.2 => /lib/libdl.so.2 (0xf752f000)
        libz.so.1 => /lib/libz.so.1 (0xf7519000)
        libc.so.6 => /lib/libc.so.6 (0xf7367000)
        /lib/ld-linux.so.2 (0xf76ea000)

so no missing symbols.
Such dependencies are not maintained for static libraries.

If you install the shared version of libcrypto, 
cmake will prefer the .so rather than the .a
and your problem should (hopefully) be solved.
[8 Feb 2013 16:07] Andrea Scarpino
Hi,
yes I'm using WITH_SSL=system. But I already have the libcrypto shared library installed. In fact, I've:
/usr/lib/libcrypto.a
/usr/lib/libcrypto.so
/usr/lib/libcrypto.so.1.0.0

openssl 1.0.1.d
[11 Feb 2013 10:01] Tor Didriksen
hello, can you try this patch:

=== modified file 'mysys_ssl/CMakeLists.txt'
--- mysys_ssl/CMakeLists.txt    2012-08-31 14:03:47 +0000
+++ mysys_ssl/CMakeLists.txt    2013-02-08 13:06:33 +0000
@@ -46,5 +46,5 @@
    )
 
 ADD_CONVENIENCE_LIBRARY(mysys_ssl ${MYSYS_SSL_SOURCES})
-TARGET_LINK_LIBRARIES(mysys_ssl dbug strings ${SSL_LIBRARIES})
+TARGET_LINK_LIBRARIES(mysys_ssl dbug strings ${SSL_LIBRARIES} ${ZLIB_LIBRARY})
 DTRACE_INSTRUMENT(mysys_ssl)
[15 Feb 2013 10:21] Andrea Scarpino
Sorry for the late reply,

Ok this is solved now, but mysql_config_editor needs the same fix too, otherwise:
Linking CXX executable mysql_config_editor
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x284): undefined reference to `deflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x344): undefined reference to `zError'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x411): undefined reference to `inflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x5e1): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x671): undefined reference to `deflateInit_'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x8a3): undefined reference to `inflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x91f): undefined reference to `zError'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x990): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xacb): undefined reference to `deflate'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xb5f): undefined reference to `zError'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xbf1): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
make[2]: *** [client/mysql_config_editor] Error 1
make[1]: *** [client/CMakeFiles/mysql_config_editor.dir/all] Error 2
make: *** [all] Error 2
[15 Feb 2013 10:37] Andrea Scarpino
Finally everything built.

To summarize:
* innochecksum needs ${ZLIB_LIBRARY}
* mysql_config_editor, mysql_plugin and mysql_upgrade needs both ${SSL_LIBRARIES} ${ZLIB_LIBRARY}
[1 Mar 2013 16:46] Paul DuBois
Noted in 5.6.11, 5.7.1 changelogs.

Configuring with -DWITH_SSL=/path/to/openssl resulted in link errors
due to selection of the incorrect libcrypto.
[7 Apr 2017 14:49] Mihai H
Hello, 

I have a similar issue using mysql-5.7.17, do you know how can be solved? The same error occurs when trying to "make". 

cmake . -DWITH_SSL=/usr -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.3 -DCMAKE_INSTALL_PREFIX=mysql-5.7.17 DWITH_BOOST=boost_1_59_0

thx.
[7 Apr 2017 14:52] Mihai H
error png

Attachment: mysql.png (image/png, text), 51.72 KiB.

[10 Apr 2017 15:46] Tor Didriksen
Posted by developer:
 
Hello, could you please try CMAKE -DWITH_SSL=system
That should ensure that you link dynamically, with libcrypto.so  rather than libcrypto.a