php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31396 Compile fails when using native libGD vs. built-in GD library
Submitted: 2005-01-04 00:14 UTC Modified: 2005-01-04 07:53 UTC
From: brooks at netgate dot net Assigned: sniper
Status: Closed Package: GD related
PHP Version: 4.3.10 OS: *
Private report: No CVE-ID:
 [2005-01-04 00:14 UTC] brooks at netgate dot net
Description:
------------
Compiling 4.3.10 with libGD (not the included GD library) without Freetype resulted the following error:

lclient -lgd -lpng -lz -lz -lm -ldl  -o sapi/cgi/php
ext/gd/gd.o: In function `zm_deactivate_gd':
ext/gd/gd.o(.text+0x8933): undefined reference to `gdFreeFontCache'
            *** Error code 1

This is similar to several other reported, yet never resolved (really) bugs (ex. 24310).

Here is the story...  libGD (2.0.33) now defines a function (dealing with FreeType) even if you don't have FreeType installed.  The function just returns a nice error message stating as much :-).  So, when the configure script for PHP tried to determine if the function was included in GD (so it could set up an ifdef statement) it found it and assumed you have Freetype support.  Unfortunately there really isn't ay FreeType support so the function (gdFreeFontCache) it tried to include (only included if you have FreeType support) caused the compile to fail with an undefined reference error.  The solution was to do a better job with the ifdef statement within the gd.c source file.

I tried to do some "tricky" stuff in the configure script.  But, it's really stupid and only cares if the damn code snippit compiles, not if it actually returns an error, or not.

I guess you might be able to change the config script to look for gdFreeFontCache() instead of gdImageStringFT() but I just added some more rules to one of the ifdef statements in gd.c to fix things, just in case the test for gdImageStringFT() for other "more useful" things.

Here is the patch to etc/gd/gd.c
Apply with patch -p0 < gd.patch

vs: {94} % more gd.patch
*** gd.c.orig   Thu Dec 23 14:14:54 2004
--- gd.c        Thu Dec 23 14:14:54 2004
***************
*** 289,295 ****
        PHP_MINIT(gd),
        NULL,
        NULL,
! #if HAVE_LIBGD20 && HAVE_GD_STRINGFT
        PHP_RSHUTDOWN(gd),
  #else
        NULL,
--- 289,298 ----
        PHP_MINIT(gd),
        NULL,
        NULL,
! // brooks
! // #if HAVE_LIBGD20 && HAVE_GD_STRINGFT
! #if HAVE_LIBGD20 && HAVE_LIBFREETYPE && HAVE_GD_STRINGFT
! // end brooks
        PHP_RSHUTDOWN(gd),
  #else
        NULL,
***************
*** 382,388 ****
  /* {{{ PHP_RSHUTDOWN_FUNCTION
   */
 
! #if HAVE_LIBGD20 && HAVE_GD_STRINGFT
  PHP_RSHUTDOWN_FUNCTION(gd)
  {
  #if defined(HAVE_GD_THREAD_SAFE) || defined(HAVE_GD_BUNDLED)
--- 385,394 ----
  /* {{{ PHP_RSHUTDOWN_FUNCTION
   */
 
! /* brooks */
! // #if HAVE_LIBGD20 && HAVE_GD_STRINGFT
! #if HAVE_LIBGD20 && HAVE_LIBFREETYPE && HAVE_GD_STRINGFT
! /* end brooks */
  PHP_RSHUTDOWN_FUNCTION(gd)
  {
  #if defined(HAVE_GD_THREAD_SAFE) || defined(HAVE_GD_BUNDLED)


Reproduce code:
---------------
PROG_SENDMAIL="/usr/sbin/sendmail" \
CFLAGS="-O3" \
LDFLAGS="-L/usr/local/lib -I/usr/local/include" \
LD_RUN_PATH="/usr/local/lib;/usr/local/mysql/lib/mysql" \
CC=/usr/bin/gcc ./configure \
        --with-mysql=/usr/local/mysql\
        --enable-force-cgi-redirect\
        --with-gd=/usr/local\
        --without-freetype\
        --without-ttf\
        --with-jpeg\
        --with-png\
        --with-png-dir=/usr/local\
        --with-zlib\
        --with-zlib-dir=/usr/local\
        --with-mm=/usr/local/mm\
        --prefix=/usr/local



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-04 06:43 UTC] sniper@php.net
It's time we start using the gdlib-config script they provide nowadays. No more hacks. :)

 [2005-01-04 07:53 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Did not make use of gdlib-config though.

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 18:01:58 2014 UTC