Redhat - Php build fails with php 5.2.6 - collect2: ld returned 1 exit status

When building php 5.2.6 if you encounter the following error during the make process:

gcc -o mkfs.jffs2 crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o compr.o -lz 

collect2: ld returned 1 exit status

Then you will need to edit the file '/usr/bin/mysql_config' and change the following lines:

libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread "
embedded_libs=" $ldflags -L$pkglibdir -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt "

TO:

libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r -lpthread -lcrypt -lnsl -lm -lpthread "
embedded_libs=" $ldflags -L$pkglibdir -lmysqld -lpthread -lcrypt -lnsl -lm -lpthread -lrt "

Once php is through building you should add the flags back.

The reason that the above error occurs is because mysql has already loaded the zlib libriries which are loaded again during the build causing a crash.