Bug #18294 4.1.16/4.1.18 generic RPM packages provides wrong zlib dependancy
Submitted: 17 Mar 2006 5:41 Modified: 6 May 2006 20:49
Reporter: K Hopkins Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.18 OS:Linux (SuSE Linux (not SLES))
Assigned to: Kent Boortz CPU Architecture:Any

[17 Mar 2006 5:41] K Hopkins
Description:
Very similar to Bug #15223 (which was RHEL4)

Installed 
Linux x86 generic RPM (dynamically linked) downloads
MySQL-client-4.1.18-0.glibc23
MySQL-server-4.1.18-0.glibc23
MySQL-Max-4.1.18-0.glibc23
MySQL-devel-4.1.18-0.glibc23
MySQL-shared-4.1.18-0.glibc23

# mysql_config
Usage: /usr/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686]
        --include        [-I/usr/include/mysql]
        --libs           [-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm]
        --libs_r         [-L/usr/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread]
        --socket         [/var/lib/mysql/mysql.sock]
        --port           [3306]
        --version        [4.1.18]
        --libmysqld-libs [-L/usr/lib/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt]

During make of applications, I'm getting errors like:
/usr/bin/sed: can't read /usr/lib/mysql/libz.la: No such file or directory
libtool: link: `/usr/lib/mysql/libz.la' is not a valid libtool archive

Originally had 4.1.16 installed, but same error occured. I found Bug #15223 and updated to 4.1.18, but it did not resolve the problem.

How to repeat:
Install SuSE 10-OSS, run online update.
Install MySQL generic RPMS (listed above)

Find some nice software that uses mysql, and try compiling it.  I'm using dbmail v2.0.9 (dbmail.org).

snokeho101:/usr/src/dbmail-2.0.9 # ./configure --with-mysql
....
checking for mysql_config... /usr/bin/mysql_config
checking MySQL headers... -I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686
checking MySQL libraries... -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm
checking for authentication configuration
using SQL authentication
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
....

snokeho101:/usr/src/dbmail-2.0.9 #
snokeho101:/usr/src/dbmail-2.0.9 # make
make  all-recursive
make[1]: Entering directory `/usr/src/dbmail-2.0.9'
Making all in mysql
make[2]: Entering directory `/usr/src/dbmail-2.0.9/mysql'
if /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I..    -I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686 -fomit-frame-pointer  -g -O2 -W -Wall -Wpointer-arith -Wstrict-prototypes -MT dbmysql.lo -MD -MP -MF ".deps/dbmysql.Tpo" -c -o dbmysql.lo dbmysql.c; \
then mv -f ".deps/dbmysql.Tpo" ".deps/dbmysql.Plo"; else rm -f ".deps/dbmysql.Tpo"; exit 1; fi
mkdir .libs
 gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686 -fomit-frame-pointer -g -O2 -W -Wall -Wpointer-arith -Wstrict-prototypes -MT dbmysql.lo -MD -MP -MF .deps/dbmysql.Tpo -c dbmysql.c  -fPIC -DPIC -o .libs/dbmysql.o
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
 gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686 -fomit-frame-pointer -g -O2 -W -Wall -Wpointer-arith -Wstrict-prototypes -MT dbmysql.lo -MD -MP -MF .deps/dbmysql.Tpo -c dbmysql.c -o dbmysql.o >/dev/null 2>&1
/bin/sh ../libtool --tag=CC --mode=link gcc -I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686 -fomit-frame-pointer  -g -O2 -W -Wall -Wpointer-arith -Wstrict-prototypes   -o libmysqldbmail.la -rpath /usr/local/lib/dbmail  dbmysql.lo -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm
gcc -shared  .libs/dbmysql.o  -L/usr/lib/mysql /usr/lib/mysql/libmysqlclient.a -lz -lcrypt -lnsl -lm  -march=i386 -mcpu=i686 -Wl,-soname -Wl,libmysqldbmail.so.0 -o .libs/libmysqldbmail.so.0.0.0
(cd .libs && rm -f libmysqldbmail.so.0 && ln -s libmysqldbmail.so.0.0.0 libmysqldbmail.so.0)
(cd .libs && rm -f libmysqldbmail.so && ln -s libmysqldbmail.so.0.0.0 libmysqldbmail.so)
ar cru .libs/libmysqldbmail.a  dbmysql.o
ranlib .libs/libmysqldbmail.a
creating libmysqldbmail.la
/usr/bin/sed: can't read /usr/lib/mysql/libz.la: No such file or directory
libtool: link: `/usr/lib/mysql/libz.la' is not a valid libtool archive
make[2]: *** [libmysqldbmail.la] Error 1
make[2]: Leaving directory `/usr/src/dbmail-2.0.9/mysql'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/dbmail-2.0.9'
make: *** [all] Error 2
snokeho101:/usr/src/dbmail-2.0.9 #

Suggested fix:
Ask Kent Boortz how he fixed #15223.
[20 Mar 2006 1:44] K Hopkins
Experimenting with other -devel files

# rpm -qlp /misc/linux/DataBase/MySQL/4.1.18/MySQL-devel-4.1.18-0.glibc23.i386.rpm > /tmp/generic-4.1.18.txt
warning: /misc/linux/DataBase/MySQL/4.1.18/MySQL-devel-4.1.18-0.glibc23.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
# rpm -qlp /misc/linux/DataBase/MySQL/sles9/MySQL-devel-standard-4.1.18-0.sles9.i586.rpm > /tmp/sles9-4.1.18.txt
warning: /misc/linux/DataBase/MySQL/sles9/MySQL-devel-standard-4.1.18-0.sles9.i586.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

# diff /tmp/generic-4.1.18.txt /tmp/sles9-4.1.18.txt  | grep -v /ndb/
30,60d29
< /usr/include/mysql/ndb
78d46
< /usr/lib/mysql/libmerge.a
90,92c58,61
< /usr/share/doc/MySQL-devel-4.1.18
< /usr/share/doc/MySQL-devel-4.1.18/EXCEPTIONS-CLIENT
< /usr/share/man/man1/mysql_config.1.gz
---
> /usr/lib/mysql/libz.a
> /usr/lib/mysql/libz.la
> /usr/share/doc/packages/MySQL-devel-standard
> /usr/share/doc/packages/MySQL-devel-standard/EXCEPTIONS-CLIENT

Why does the -devel pack for RHEL & SLES contain libz.la but the generic rpm -devel does not?
[10 Apr 2006 4:05] Christoper Thompson
G'Day folks,

Just a small observation. This may help to solve the problem, however, you will need to test it on your platform.
I have tested this on RH-9, RHEl-3 & WB-ENT-3. It seems to work.

Specifically, you will notice both spec files (generic & RHEL) have two blocks that control compile options.
The first, from the 4.18 generic;

# The --enable-assembler simply does nothing on systems that does not
# support assembler speedups.
sh -c  "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \
        CC=\"${CC:-$MYSQL_BUILD_CC}\" \
        CXX=\"${CXX:-$MYSQL_BUILD_CXX}\" \
        CFLAGS=\"${MYSQL_BUILD_CFLAGS:-$RPM_OPT_FLAGS}\" \
        CXXFLAGS=\"${MYSQL_BUILD_CXXFLAGS:-$RPM_OPT_FLAGS \
                  -felide-constructors -fno-exceptions -fno-rtti \
                  }\" \
        ./configure \
            $* \
            --enable-assembler \
            --enable-local-infile \
            --with-mysqld-user=%{mysqld_user} \
            --with-unix-socket-path=/var/lib/mysql/mysql.sock \
            --prefix=/ \
            --with-extra-charsets=complex \
            --exec-prefix=%{_exec_prefix} \
            --libexecdir=%{_sbindir} \
            --libdir=%{_libdir} \
            --sysconfdir=%{_sysconfdir} \
            --datadir=%{_datadir} \
            --localstatedir=%{mysqldatadir} \
            --infodir=%{_infodir} \
            --includedir=%{_includedir} \
            --mandir=%{_mandir} \
            --enable-thread-safe-client \
            --with-readline ;
            # Add this for more debugging support
            # --with-debug
            # Add this for MyISAM RAID support:
            # --with-raid
            "
The second, also from the 4.18 generic;

BuildMySQL "--enable-shared \
                --without-openssl \
                --with-berkeley-db \
                --with-innodb \
                --with-ndbcluster \
                --with-raid \
                --with-archive-storage-engine \
                --with-csv-storage-engine \
                --with-example-storage-engine \
                --with-blackhole-storage-engine \
                --with-embedded-server \
                --with-comment=\"MySQL Community Edition - Max (GPL)\" \
                --with-server-suffix='-Max'"

make test-force || true
 
For conveniance, we will refer to all RPM spec files as 'rpm spec' files.
For further conveniance, we will refer to the blocks as 'mysql build' & 'max build', for want of a better reference.

The difference for the zlib option in the 'rpm spec'  files is one line in the second block, AKA the 'max build' section.

This line is '--with-zlib-dir=bundled'

This, according to the provided documentation, uses the bundled version of the zlib '1.2.3' version supplied with the source.

The important thing is to only add this option to the second block, AKA the 'max build' section.

This option can be manually added to the 'spec' file after you have unpacked the src rpm, but before you start the compile. 

Should you have problems with a binary, then the modified source spec file method, may be for you.
One further note. 
As I have a need to develop custom versions, I include in the top of my 'rpm spec'  file, a few custom defines, usually after the existing block of (%defines), like this example;

%define mysql_ext  --enable-assembler --enable-local-infile \

%define max_ext  --with-zlib-dir=bundled --with-openssl --with-isam \

Then, in the required block, in this example, the second block, AKA the 'max build' section, we add our custom define, thus;

BuildMySQL "--enable-shared \
                --without-openssl \
                --with-berkeley-db \
                --with-innodb \
                --with-ndbcluster \
                --with-raid \
                --with-archive-storage-engine \
                --with-csv-storage-engine \
                --with-example-storage-engine \
                --with-blackhole-storage-engine \
                --with-embedded-server \
                --with-comment=\"MySQL Community Edition - Max (GPL)\" \
                --with-server-suffix='-Max'
                %{max_ext}
               "
Note: the quotation at the end of the line in the first example was moved down to the line below, in the second example. 
Exercise care when playing, missing silly little things can consume time and hurt your brain.

The important thing to note is the two compile blocks often require seperate options, hence the use of two sperate defines.
This solution should be universal and seems to work with all versions of RPM in version 4xx.

So, if all and sundry having problems could take test the 'zlib = bundled' solution, via the source rpm solution, let's see if it fixes the problem. 

You may need to update youre existing zlib (http://zlib.net/) prior to installing 'mysql' on some platforms.
Should this be the case, please document it & let the guys & girls at MySQL know.

Regards,
[10 Apr 2006 15:52] Christoper Thompson
**************************************************************************
Please note this is an addendum to the previous message.

This is what happens when you fail to check things, regardless of the reasons.

** Please note that the generic RPM 'spec file' is missing the required library paths for the 'zlib' librarys.
They are built, but not installed.

An examination of the RHEL-3 'spec file', compared to the generic version, will show what I mean. 
Specifically, at the bottom of the file, in the;
' '%files -n MySQL-devel%{server_suffix}' 
section, you will note the differnce between the generic version and a platform specific version.

A simple long term solution is the judicous use of a few more defines, wrapped in an {if..endif} block.
The short term, one off solution, is to "cut and paste" or otherwise manually add, the required lines into your 'spec file'.

Please note that it is quite safe to install RPM source code from any linux RPM platform to any other, in particular, for comparision purposes. 
The real trouble only starts if you attempt an 'RPMBUILD', if the source RPM is not suited to your platform, SO, DON'T do that.

This appears to be a universal problem, so a long term solution needs a more review and tested, universal solution. 

Meanwhile, the cut and paste solution should work on most platforms.

I will note any further conditons and outcomes, based on mine.
(RHEL-3 / WB-ent-3 / RH-9)

I will be likley installing / testing CENTOS-4 over easter.
That is around week (3) (April 2006). I will advise any adverse, or other, outcomes.

Regards,
**************************************************************************
[11 Apr 2006 20:46] Aaron
Hi, I would just like to say that I made a bug report for the same issue, I think. I did not see this bug report. Here is what my (now closed) bug report said:

Description:
Compiling PHP with MySQL support does not work. It gives this error:

grep: /usr/lib/mysql/libz.la: No such file or directory
/bin/sed: can't read /usr/lib/mysql/libz.la: No such file or directory
libtool: link: `/usr/lib/mysql/libz.la' is not a valid libtool archive
make: *** [libphp5.la] Error 1

This has been brought up in other bug reports. Those bug reports have been
closed because the bug has apparently been fixed, but it HAS NOT been fixed. I
am using MySQL client/devel 4.1.18 and it does not work.

If I downgrade to 4.1.15, it works flawlessly.

The other bug reports are here:

http://bugs.mysql.com/bug.php?id=15223
http://bugs.mysql.com/bug.php?id=16595

PLEASE fix this.

How to repeat:
Install the latest MySQL RPMs and try to compile PHP.

I am using Fedora (Core 3 and Core 4)
[28 Apr 2006 23:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/5694
[6 May 2006 20:27] Aaron
Woohoo! This is fixed in 4.1.19! I can confirm it as I just tested it and all is well. Thanks guys!
[6 May 2006 20:49] Hartmut Holzgraefe
Thank you for your bug report. This issue has already been fixed
in the latest released version of that product, which you can download at 
http://www.mysql.com/downloads/