Linux – Compile freetype support in php

apache-2.2centoslinuxPHP

I'm not able to compile freetype support in php…

My configure command is:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-bcmath 
--enable-zip --with-zlib --with-gd --with-jpeg-dir=/usr/lib --with-mysqli 
--enable-mbstring --with-pdo-mysql  --with-pgsql=/usr/lib/pgsql 
--with-freetype-dir=/usr/lib --enable-gd-native-ttf

and it runs fine (doesn't complain about anything), compilation is succesful too, but in the end freetype support is not enabled:

["GD Version"]=> string(27) "bundled (2.0.34 compatible)" 
["FreeType Support"]=> bool(false)
["T1Lib Support"]=> bool(false) 

/usr/lib looks like the right place to look for freetype:

# pwd
/usr/lib
# ll|grep -i freetype
lrwxrwxrwx   1 root root       21 Dec 10 13:35 libfreetype.so -> libfreetype.so.6.3.10
lrwxrwxrwx   1 root root       21 Dec 10 13:35 libfreetype.so.6 -> libfreetype.so.6.3.10
-rwxr-xr-x   1 root root   525448 Nov 16 17:55 libfreetype.so.6.3.10

OS is Centos Linux 5, php version is 5.2.17.

Any hints? Thanks!

Best Answer

Since this question is about compiling PHP with FreeType support and not installing it, I wanted to add to this just in case someone else (like me) is having this problem and needs to compile a version of PHP that isn't available as a package.

  1. First, you will need the FreeType library installed either by downloading and compiling it from http://freetype.org/download.html or by installing the package available with your operating system.
  2. The first problem is the path specified with --with-freetype-dir isn't correct. You want the include directory and not the lib directory of freetype. In my case (on CentOS v6.7), the directory was /usr/include/freetype2. You can find this by running find / -name freetype2.
  3. Now that part is sorted, you can run ./configure with the --with-freetype-dir argument that was determined above. In the case of this question, the full command would be ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-bcmath --enable-zip --with-zlib --with-gd --with-jpeg-dir=/usr/lib --with-mysqli --enable-mbstring --with-pdo-mysql --with-pgsql=/usr/lib/pgsql --with-freetype-dir=/usr/include/freetype2 --enable-gd-native-ttf
  4. If you already compiled PHP before this, you need to run make clean first. The configuration has changed so all of the objects to wiped be recompiled.
  5. Run make and then make install to compile PHP.
  6. Verify that FreeType is installed by running php -i or viewing the output of phpinfo();. If using a web server, you may need to restart it for the changes to come into effect.