Skip navigation

GDChart is a fairly old PHP extension, it’s origins are somewhere in 2003 and doesn’t seem to have been updated since 2006. The standard PECL sources won’t compile under any version of PHP greater than 5.3 due to a few changes in the Zend engine and GD dependencies. If you try, you’ll get a few error messages:
/gdchart-0.2.0/gdchart.c:195: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gdchart_functions’
/gdchart-0.2.0/gdchart.c: In function ‘gdc_objects_new’:
/gdchart-0.2.0/gdchart.c:303: error: ‘zend_class_entry’ has no member named ‘default_properties’
/gdchart-0.2.0/gdchart.c: At top level:
/gdchart-0.2.0/gdchart.c:360: error: ‘gdchart_functions’ undeclared here (not in a function)

If you’re in a hurry or your C/C++ is a little rusty you’re in luck, this is how to fix it. In the source file gdchart-0.2.0/gdchart.c perform these replacements:

195c195
< function_entry gdchart_functions[] = {
---
> zend_function_entry gdchart_functions[] = {
303c303
< 	zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
---
> 	object_properties_init((zend_object*) &(intern->zo), class_type);

Then perform the usual extension compilation routine:
gdchart-0.2.0]$ phpize
gdchart-0.2.0]$ ./configure
gdchart-0.2.0]$ make && make test

As you can see, you’re not done. Don’t try to install this module yet it won’t load, failing with PHP Warning: PHP Startup: Unable to load dynamic library '/home/jack/build/gdchart-0.2.0/modules/gdchart.so' - /home/jack/build/gdchart-0.2.0/modules/gdchart.so: undefined symbol: php_gd_gdFontMediumBold in Unknown on line 0

Now we have to patch some PHP GD core files to accommodate changes in the visibility of a few GD resources, fortunately we have a patch for that here:https://github.com/arete/t2/blob/master/package/php/php/libgd-symbol-visibility.patch.

After patching the PHP sources, recompile and install along with the GDChart extension. Or do what any sane person would do and use a more recent and maintained visualization library like PHPlot, pChart or Google Charts.