I run my web servers by compiling the most important components from source code, which makes it possible for me to add security fixes more quickly and fine-tune my installations of Apache, MySQL and PHP. While compiling the new release PHP 5.2.8 this weekend, the process failed with this error:
/usr/bin/ld: /usr/mysql/lib/mysql/libz.a(compress.o): relocation R_X86_64_32 against 'a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/mysql/lib/mysql/libz.a: could not read symbols: Bad value
Naturally, I had absolutely no idea what this meant.
The file libz.a is part of the Zlib compression library, which apparently is included in MySQL 5.0. A Google search for the error message uncovered a bunch of people suffering the same problem I encountered when compiling programs on Linux. The best explanation I found was a Gentoo Linux page on how to fix -fPIC errors. Unfortunately, none of Gentoo's tips worked for me.
Through trial and error (and error and error), I finally solved the problem by compiling a new copy of Zlib and specifying that it create a Unix shared library using the option:
Next, I added the option when running configure to prepare PHP for installation. This didn't work until I figured out one last obstacle -- the Zlib option must be placed before the option. Otherwise, PHP tries to use the copy of Zlib included with MySQL.
Everything now compiles and runs successfully. So until the next time I try to install something, I can return my ego to its upright position. My new Linux technique is unstoppable.
