|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46015 Build fails with system gd
Submitted: 2008-09-07 07:21 UTC Modified: 2009-08-17 08:42 UTC
Avg. Score:4.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: Fedora at FamilleCollet dot com Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 5.3.0alpha2 OS: Linux (Fedora 9)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Fedora at FamilleCollet dot com
New email:
PHP Version: OS:


 [2008-09-07 07:21 UTC] Fedora at FamilleCollet dot com
Build fails when trying to use system GD


This is because gdhelpers only provided by bundled library.

Trivial patch proposal :
--- ext/gd/gd.c.orig	2008-09-07 08:53:38.000000000 +0200
+++ ext/gd/gd.c	2008-09-07 08:54:03.000000000 +0200
@@ -74,7 +74,9 @@
 #include <gdfontmb.h> /* 3 Medium bold font */
 #include <gdfontl.h>  /* 4 Large font */
 #include <gdfontg.h>  /* 5 Giant font */
 #include <gdhelpers.h>
 #ifdef HAVE_GD_WBMP
 #include "libgd/wbmp.h"

Reproduce code:

Expected result:
Build complete.

Actual result:
Build failed.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-08 10:26 UTC]
Had the same problem and came up with similar fix. Would someone apply 
this patch to CVS? My karma is not sufficient.
 [2008-09-08 10:57 UTC]
This patch is not correct as then the function defined in gdhelper.h will not be defined and the default signature will be used. please do not apply it, I will fix the issue while working on another similar issue in gd.
 [2008-12-05 08:56 UTC] karsten at typo3 dot org
I had the same issue yesterday and switched to the bundled GD to make it 
compile. Now, it would be interesting to know what functionality 
difference this means and what the other issue is, this is related to.
 [2008-12-05 09:13 UTC]
The bundled GD is the recommend version anyway. It has more bug fixes and features than almost all GD distributions out there (the worst is debian's gd which should not be used at all).

Functions like imagefilter, imagerotate are not available when an external GD is used.

php6 may support external GD but only a recent version and only when a minimum set of features are enabled.
 [2008-12-05 18:53 UTC] php-bugs-2008 at ryandesign dot com
Thanks for letting us know why specifically the bundled libgd is superior (the imagefilter and imagerotate functions). Given this, I will switch MacPorts php5 back to using the bundled libgd.

You must admit however there is room for confusion. The first sentence on the installation instructions [1] says "If you have the GD library (available at ? you will also be able to create and manipulate images." And the libgd homepage in turn says "The library [...] is now maintained by Pierre-A. Joye under the umbrella of" This gives the impression that the standalone libgd is being developed by the same people who develop PHP's bundled libgd. The note further down the installation instructions reads "Since PHP 4.3 there is a bundled version of the GD lib [which] should be used in preference to the external library since its codebase is better maintained and more stable." Because PHP 4.3 is so old, someone reading this note might well assume the information is outdated, and that since libgd is now under's umbrella, the unique changes in PHP's bundled libgd are now in the standalone libgd as well.

php5 has supported standalone libgd, up to and including php 5.3.0 alpha 1. So it would be good if php 5.3.0 final did not break this. Or, if it is your intention to break this, then do so with a friendlier message in the configure phase and update the documentation.

 [2009-03-27 18:03 UTC] tsteiner at nerdclub dot net
This is still an issue in 5.3.0RC1.  If building against an external version of GD is no longer supported, the configure script should probably be updated to throw an error or at least a warning should one try to do so.  Currently, the build just fails during "make" with the error:

ext/gd/gd.c:72:23: error: gdhelpers.h: No such file or directory

leaving the user with no idea what to do.
 [2009-03-27 18:50 UTC] tsteiner at nerdclub dot net
Here's a quick patch that removes support for building against an external libgd and replaces it with an error message.  It seems to work as intended but I am by no means experienced with the autoconf system.

--- php-5.3.0RC1.orig/ext/gd/config.m4       2009-01-14 13:05:59.000000000 -0600
+++ php-5.3.0RC1/ext/gd/config.m4   2009-03-27 13:42:01.071603975 -0500
@@ -262,7 +262,6 @@
 if test "$PHP_GD" = "yes"; then
-  GD_MODULE_TYPE=builtin
   extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \
                  libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_png.c libgd/gd_jpeg.c \
                  libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c libgd/gdfontl.c \
@@ -339,57 +338,7 @@
  if test "$PHP_GD" != "no"; then
-  GD_MODULE_TYPE=external
-  extra_sources="gdcache.c"
-dnl Various checks for GD features
-dnl Header path
-  for i in include/gd1.3 include/gd include gd1.3 gd ""; do
-    test -f "$PHP_GD/$i/gd.h" && GD_INCLUDE="$PHP_GD/$i"
-  done
-dnl Library path
-  for i in $PHP_LIBDIR/gd1.3 $PHP_LIBDIR/gd $PHP_LIBDIR gd1.3 gd ""; do
-    test -f "$PHP_GD/$i/libgd.$SHLIB_SUFFIX_NAME" || test -f "$PHP_GD/$i/libgd.a" && GD_LIB="$PHP_GD/$i"
-  done
-  if test -n "$GD_INCLUDE" && test -n "$GD_LIB"; then
-  elif test -z "$GD_INCLUDE"; then
-    AC_MSG_ERROR([Unable to find gd.h anywhere under $PHP_GD])
-  else
-    AC_MSG_ERROR([Unable to find libgd.(a|so) anywhere under $PHP_GD])
-  fi
-  dnl
-  dnl Check for gd 2.0.4 greater availability
-  dnl
-#include <gd.h>
-#include <stdlib.h>
-  ], [
-gdIOCtx *ctx;
-ctx = malloc(sizeof(gdIOCtx));
-ctx->gd_free = 1;
-  ], [
-    AC_DEFINE(HAVE_LIBGD204, 1, [ ])
-  ])
+  AC_MSG_ERROR([Building the GD extension against an external libgd is not supported.])
@@ -399,23 +348,13 @@
 if test "$PHP_GD" != "no"; then
   PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS))
-  if test "$GD_MODULE_TYPE" = "builtin"; then
-    GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
-    PHP_ADD_BUILD_DIR($ext_builddir/libgd)
-    GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
-    PHP_TEST_BUILD(foobar, [], [
-      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
-    ], [ $GD_SHARED_LIBADD ], [char foobar () {}])
-  else
-    GD_HEADER_DIRS="ext/gd/"
-    PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
-      AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
-    ], [ -L$GD_LIB $GD_SHARED_LIBADD ])
-  fi
+  GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
+  PHP_ADD_BUILD_DIR($ext_builddir/libgd)
+  GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
+  PHP_TEST_BUILD(foobar, [], [
+    AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
+  ], [ $GD_SHARED_LIBADD ], [char foobar () {}])
 [2009-04-07 09:27 UTC]
Please try using this CVS snapshot:
For Windows:

 [2009-04-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-08-17 08:42 UTC]
Fixed in 5.3.0 and later.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jun 03 01:03:41 2023 UTC