go to bug id or search bugs for
New/Additional Comment:
Description:
------------
previously filed "", but that was rejected as "not a bug"...
However, there is no way currently to build PHP with libgd, but without XPM. We don't want XPM, some suggested on the web to install XPM so that they could succeed building PHP.
Therefor I file this 'change request':
1) when "libgd" (version 2.1.0) is 'configure'd with "--without-xpm", it will include anyhow a function "gdImageCreateFromXpm ()" from file 'src/gdxpm.c' with
#ifndef HAVE_LIBXPM
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
{
(void)filename;
gd_error_ex(GD_ERROR, "libgd was not built with xpm support\n");
return NULL;
}
#else
#include <X11/xpm.h>
...
2) when "php" (version 5.5.9) is 'configure'd with "--with-xpm-dir=no" then it runs as follows:
...
configure:37479: checking for the location of libXpm
configure:37494: result: no
...
configure:42617: checking for gdImageCreateFromXpm in -lgd
configure:42642: /our_base_dir/bin/gcc -o conftest -m32 -I/our_base_dir/include -fvisibility=hidden -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -L/our_base_dir/lib -lxml2 -m32 -R/usr/ucblib -L/usr/ucblib -R/our_base_dir/lib/gcc/sparc-sun-solaris2.10/4.7.1 -L/
our_base_dir/lib/gcc/sparc-sun-solaris2.10/4.7.1 -R/our_base_dir/lib -L/our_base_dir/lib conftest.c -lgd -lgd -lpng -lz -lpng -lz -lz -lrt -lm -lnsl -lsocket -lgcc -lxml2 -lz -lm -lso
cket -lnsl -lxml2 -lz -lm -lsocket -lnsl >&5
configure:42642: $? = 0
configure:42651: result: yes
...
With the "conftest.c" file containing a call to that function "gdImageCreateFromXpm()", to see if the compiler finds that function in the "libgd.so.3.0.0" library, which it does despite that we disabled the support for XPM in the building of LIBGD.
$ cat conftest.c
#ifdef __cplusplus
extern "C"
#endif
char gdImageCreateFromXpm ();
int
main ()
{
return gdImageCreateFromXpm ();
;
return 0;
}
After "configure" is done, the "config.status" contains the flag
D["HAVE_GD_XPM"]=" 1"
so that PHP will attempt to build with X11 support, and fails during compilation because we do not (and don't want) have the X11 libraries installed:
...
/bin/bash /our_base_dir/php-5.5.9/libtool --silent --preserve-dup-deps --mode=link /our_base_dir/bin/gcc ... -o sapi/cli/php
Undefined first referenced
symbol in file
XpmLibraryVersion ext/gd/.libs/gd.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: error: ld returned 1 exit status
make[2]: *** [sapi/cli/php] Error 1
This is because in "ext/gd/gd.c" the code will call XpmLibraryVersion() when the flag "HAVE_GD_XPM" has value '1' :
...
#if defined(HAVE_GD_XPM)
php_info_print_table_row(2, "XPM Support", "enabled");
{
char tmp[12];
snprintf(tmp, sizeof(tmp), "%d", XpmLibraryVersion());
php_info_print_table_row(2, "libXpm Version", tmp);
}
#endif
...
Conclusion:
the PHP configure script is not checking correctly if the libgd contains XPM or not: libgd will always contain that function gdImageCreateFromXpm(), but that function will just return a different value depending on with- or without-XPM was specified.
PHP configure script should therefor test on the return value of that function gdImageCreateFromXpm(), not just if the test program can be linked correctly with the libgd library.
A fix can be this: modify the line in 'configure' such that it does not only check if that function gdImageCreateFromXpm() can be found in the libgd library (because it always will be there anyhow) but call it and check if it returns NULL indicating that there is no XPM support in the libgd :
in 'configure':
replace this:
return gdImageCreateFromXpm ();
by this:
if(gdImageCreateFromXpm()!=NULL){return 1;}else {return 0;}
With this change, PHP builds just fine on Solaris-10, using GCC, and libgd (v2.1.0) but without any X11/XPM installed !
Add a Patch
Add a Pull Request
I have this problem, thank you for your analysis and resolution, It helps a lot!
The relevant check in ./configure is generated by
PHP_CHECK_LIBRARY()[1], which is obviously insufficient to check
for XPM support in an external libgd as elaborated by the OP.
As the check does not fulfill its purpose, this is a bug.
[1] <>
I ran into this in version 5.6.20 on AIX
workaround in the main/php_config.h comment out:
#define HAVE_GD_XPM 1
make clean; make
the issue exists in 5.6.35