Bug #14151 Adding --with-zlib-dir on FreeBSD 4.x causes build failure
Submitted: 19 Oct 2005 20:26 Modified: 22 Jul 2007 17:53
Reporter: Luke Hollins Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0.15, 5.0-13-rc OS:FreeBSD (FreeBSD 4.7, 4.11)
Assigned to: Joerg Bruehe CPU Architecture:Any

[19 Oct 2005 20:26] Luke Hollins
Description:
When not using the --with-zlib-dir= option, configure picks up /usr/lib /usr/include and mysql builds fine. But then using the configure option --with-zlib-dir=/usr , configure says
checking for zlib compression library... ok

The build then fails with:

Making all in mysys
gmake[2]: Entering directory `/usr/local/src/mysql-5.0.13-rc/mysys'
source='md5.c' object='md5.o' libtool=no \
depfile='.deps/md5.Po' tmpdepfile='.deps/md5.TPo' \
depmode=gcc /bin/sh ../depcomp \
gcc -DDEFAULT_BASEDIR=\"/usr/local\" -DDATADIR="\"/usr/local/var\"" -DDEFAULT_CHARSET_HOME="\"/usr/local\"" -DSHAREDIR="\"/usr/local/share/mysql\"" -DDEFAULT_HOME_ENV=MYSQL_HOME -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include -I../include -I../include -I.    -O3 -DDBUG_OFF    -c md5.c
md5.c:71: syntax error before `PROTO_LIST'
md5.c:72: syntax error before `PROTO_LIST'
md5.c:74: syntax error before `PROTO_LIST'
md5.c:127: syntax error before `*'
md5.c: In function `my_MD5Init':
md5.c:129: `context' undeclared (first use in this function)
md5.c:129: (Each undeclared identifier is reported only once
md5.c:129: for each function it appears in.)
md5.c: At top level:
md5.c:144: syntax error before `*'
md5.c: In function `my_MD5Update':
md5.c:151: `context' undeclared (first use in this function)
md5.c:155: `UINT4' undeclared (first use in this function)
md5.c:155: syntax error before `inputLen'
md5.c:156: syntax error before `inputLen'
md5.c:158: syntax error before `inputLen'
md5.c:164: `inputLen' undeclared (first use in this function)
md5.c:165: `POINTER' undeclared (first use in this function)
md5.c:165: syntax error before `input'
md5.c:169: `input' undeclared (first use in this function)
md5.c: At top level:
md5.c:187: syntax error before `my_MD5_CTX'
md5.c: In function `my_MD5Final':
md5.c:193: `context' undeclared (first use in this function)
md5.c:205: `digest' undeclared (first use in this function)
md5.c:209: `POINTER' undeclared (first use in this function)
md5.c:209: syntax error before `context'
md5.c: At top level:
md5.c:215: syntax error before `state'
md5.c:217: warning: `MD5Transform' was declared implicitly `extern' and later `static'
md5.c:166: warning: previous declaration of `MD5Transform'
md5.c:217: warning: type mismatch with previous implicit declaration
md5.c:166: warning: previous implicit declaration of `MD5Transform'
md5.c:217: warning: `MD5Transform' was previously implicitly declared to return `int'
md5.c: In function `MD5Transform':
md5.c:218: syntax error before `a'
md5.c:220: `x' undeclared (first use in this function)
md5.c:220: `block' undeclared (first use in this function)
md5.c:223: `a' undeclared (first use in this function)
md5.c:223: `b' undeclared (first use in this function)
md5.c:223: `c' undeclared (first use in this function)
md5.c:223: `d' undeclared (first use in this function)
md5.c:223: `UINT4' undeclared (first use in this function)
... lots more

the configure log is here:
configure:25021: checking for zlib compression library
configure:25167: gcc -o conftest      conftest.c -lcrypt -lm  -L/usr/lib -lz >&5
configure:25173: $? = 0
configure:25177: test -z
          || test ! -s conftest.err
configure:25180: $? = 0
configure:25183: test -s conftest
configure:25186: $? = 0
configure:25189: result: ok
configure:25856: checking if we should use pstack
configure:25858: result:
configure:26040: checking for int8
configure:26082: gcc -o conftest      conftest.c -lcrypt -lm  >&5
conftest.c: In function `main':
conftest.c:92: syntax error before `i'
configure:26085: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING "" 
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE "mysql"
| #define VERSION "5.0.13-rc"
| #define HAVE_CHARSET_latin1 1
| #define HAVE_CHARSET_latin1 1
| #define HAVE_CHARSET_utf8 1  
| #define USE_MB 1
| #define USE_MB_IDENT 1
| #define MYSQL_DEFAULT_CHARSET_NAME "latin1"
| #define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
| #define HAVE_UCA_COLLATIONS 1
| #define PROTOCOL_VERSION 10
| #define DOT_FRM_VERSION 6
| #define NDB_VERSION_MAJOR 5
| #define NDB_VERSION_MINOR 0 
| #define NDB_VERSION_BUILD 13
| #define NDB_VERSION_STATUS "rc"
| #define SYSTEM_TYPE "unknown-freebsd4.11"
| #define MACHINE_TYPE "i386"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1   
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define SPRINTF_RETURNS_INT 1
| #define HAVE_EXPLICIT_TEMPLATE_INSTANTIATION 1
| #define HAVE_DIRENT_H 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_FLOAT_H 1
| #define HAVE_FLOATINGPOINT_H 1
| #define HAVE_IEEEFP_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_PWD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STDDEF_H 1   
| #define HAVE_STRINGS_H 1
| #define HAVE_STRING_H 1
| #define HAVE_SYS_MMAN_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_NETINET_IN_H 1
| #define HAVE_ARPA_INET_H 1
| #define HAVE_SYS_TIMEB_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_UN_H 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_TERM_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_UTIME_H 1
| #define HAVE_TERMIOS_H 1
| #define HAVE_SCHED_H 1
| #define HAVE_SYS_IOCTL_H 1
| #define HAVE_MALLOC_H 1
| #define HAVE_SYS_MALLOC_H 1
| #define HAVE_SYS_IPC_H 1
| #define HAVE_SYS_SHM_H 1
| #define HAVE_SYS_RESOURCE_H 1   
| #define HAVE_SYS_PARAM_H 1 
| #define HAVE_LIBM 1
| #define HAVE_LIBCRYPT 1
| #define HAVE_CRYPT 1
| #define HAVE_COMPRESS 1
| /* end confdefs.h.  */
| 
| #ifdef HAVE_STDLIB_H
| #include <stdlib.h>
| #endif
| | 
| #ifdef HAVE_STDDEF_H   
| #include <stddef.h>   
| #endif
| 
| #ifdef HAVE_SYS_TYPES_H   
| #include <sys/types.h> 
| #endif
| 
| int main()
| {
|   int8 i;
|   return 0;
| }
| 
configure:26105: result: no

How to repeat:
use --with-zlib-dir and point to a valid zlib prefix
[24 Oct 2005 15:22] Valeriy Kravchuk
Thank you for a problem report. I've tried to repeat it on our FreeBSD 4.7 machine with 5.1.15 GA official sources. Everything looks just as you described. I've performed the following commands:

gunzip < mysql-5.0.15.tar.gz | tar xvf -
cd mysql-5.0.15
./configure --with-zlib-dir=/usr --prefix=/usr/home/mysqldev/valeriy/dbs/5.0
make

and got just the error messages you informed about:

md5.c:71: syntax error before `PROTO_LIST'
md5.c:72: syntax error before `PROTO_LIST'
md5.c:74: syntax error before `PROTO_LIST'
md5.c:127: syntax error before `*'
md5.c: In function `my_MD5Init':
md5.c:129: `context' undeclared (first use in this function)
md5.c:129: (Each undeclared identifier is reported only once
md5.c:129: for each function it appears in.)
md5.c: At top level:
md5.c:144: syntax error before `*'
...

But please, explain, why you set /usr as --with-zlib-dir value? Do you really have zlib in /usr? If it was a mistake, then why do you expect that configure should produce a working builds with any arbitrary values?
[24 Oct 2005 21:42] Luke Hollins
I do have zlib in /usr , I had the configure option --with-zlib-dir=/usr set because in the past I had another zlib the ldconfig search path and wanted MySQL to pickup the /usr copy.
[25 Oct 2005 11:18] Valeriy Kravchuk
OK. In my case there was a zlib files in include/ and lib/ subdirectoriers of /usr, so it is a bug:

gcc ... -I. -I. -I.. -I/usr/include -I../include -I../include -I. ... -c md5.c

Here /usr/include is listed before the ../include, and /usr/include/md5.h is used always because of that.
[10 Apr 2006 16:03] Christoper Thompson
**************************************************************************
Please note the contents of #18294

This is much the same problem.

Also, this 'zlib' problem needs a fix, as other packages that use MySQL, such as PHP, need the 'zlib libarys' correctly installed in MySQL.
The reason PHP needs it, is the PHP (vers. 4.18+) applications that use LAMP & ZLIB, need it.

Regards,

**************************************************************************
[18 Jul 2007 12:17] Joerg Bruehe
I don't have a BSD available locally, will try on Linux first.

Starting based on MySQL 5.0.46 + first changes for 5.0.48
on a SuSE 10.2 machine with this setting:

joerg@trift-lap:~> rpm -qa | grep zlib
zlib-devel-1.2.3-33
zlib-1.2.3-33
joerg@trift-lap:~> rpm -ql zlib-1.2.3-33 zlib-devel-1.2.3-33 | xargs ls -ld
lrwxrwxrwx 1 root root    13  1. Feb 19:41 /lib/libz.so.1 -> libz.so.1.2.3
-rwxr-xr-x 1 root root 72020 25. Nov 2006  /lib/libz.so.1.2.3
-rw-r--r-- 1 root root  9544 25. Nov 2006  /usr/include/zconf.h
-rw-r--r-- 1 root root 66259 25. Nov 2006  /usr/include/zlib.h
-rw-r--r-- 1 root root  6859 25. Nov 2006  /usr/include/zutil.h
lrwxrwxrwx 1 root root     6  1. Feb 20:43 /usr/lib/libgz.a -> libz.a
lrwxrwxrwx 1 root root    14  1. Feb 19:41 /usr/lib/libgz.so.1 -> /lib/libz.so.1
-rw-r--r-- 1 root root 87916 25. Nov 2006  /usr/lib/libz.a
lrwxrwxrwx 1 root root    14  1. Feb 20:43 /usr/lib/libz.so -> /lib/libz.so.1
drwxr-xr-x 2 root root  4096  1. Feb 19:41 /usr/share/doc/packages/zlib
-rw-r--r-- 1 root root 42928 18. Jul 2005  /usr/share/doc/packages/zlib/ChangeLog
-rw-r--r-- 1 root root  5696 18. Jul 2005  /usr/share/doc/packages/zlib/README
-rw-r--r-- 1 root root  9336  2. Jun 2003  /usr/share/doc/packages/zlib/algorithm.txt
-rw-r--r-- 1 root root  2082 25. Nov 2006  /usr/share/man/man3/zlib.3.gz
joerg@trift-lap:~>
[18 Jul 2007 16:44] Joerg Bruehe
I cannot repeat the problem, using a setup as described in my previous entry.

Regardless whether I use
  ./configure
or
  ./configure --with-zlib-dir=/usr
both the configure and the compile/link phase will access the zlib header and library files from /usr/include and /usr/lib.

I will try to find a FreeBSD environment and try there,
but I would also like to get feedback whether that is still a problem with current versions.

(And yes, I am sorry we did not turn to this bug report sooner -
all I can say is that we haven't been idle.)
[19 Jul 2007 10:48] Joerg Bruehe
I was misled, because I had got the notion that the value of the "--with-zlib-dir=" option had not been honored, and my tests showed it was.

I also checked FreeBSD 4.7 and found the value was honored,
"./configure --with-zlib-dir=/usr" failed because the zlib installed on the system was too old, it is version 1.1 while the MySQL server requires 1.2 with function "zlibCompileFlags()".

It took some time till I found that the real issue is not about using zlib,
it is the conflict about selecting the proper file "md5.h"
(the system-provided version in "/usr/include", or the one coming with the MySQL sources).

BTW: The hint to bug 18294 is misleading, that really was a zlib issue.
[19 Jul 2007 17:32] 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/31185

ChangeSet@1.2532, 2007-07-19 14:14:03+02:00, joerg@trift-lap.none +8 -0
  Avoid the name conflict between the system-provided "md5.h" and the MySQL one
  by renaming "include/md5.h" to "include/my_md5.h".
  
  Fixes bug#14151.
[20 Jul 2007 12:02] Joerg Bruehe
Expected to be included in 5.0.48 and 5.1.21
(subject to testing on all platforms).
[22 Jul 2007 9:41] Bugs System
Pushed into 5.0.48
[22 Jul 2007 9:43] Bugs System
Pushed into 5.1.21-beta
[22 Jul 2007 17:53] Paul DuBois
No changelog entry needed.