Error on compiling php for GD on SOLARIS 10

Hi everyone,

I have SUn E250 server running solaris 10. I have installed apache 2 + MySQL + PHP-5.1.4 following the guidelines on this website
http://meljr.com/~meljr/AMPSolaris10.html

Excellent document for first time installation. Now, because I wanted to use Coppermine Photo Gallery, I realised I required GD or ImageMagick.

So I decided to go for GD2. I didn't realise that PHP already had GD2 installed as a extension. So I checked my installed director /usr/local/include/php/ext .... no GD and checked phpinfo.php no GD listed.

An since I had no idea how to use that extension file from /php-5.1.4/ext/gd folder, I decided to download GD and build it from source. As requirement of GD, i installed libraries for png, jpeg, zlib and many more and all were installed into /usr/local/lib (thats what I think as I saw all the lib files there).

Anyways then to combine gd with php, I decided to recompile php with the following options..... plz note I executed the ./configure command under the
/php-5.1.4 directory.

./configure --with-apxs2=/usr/apache2/bin/apxs \
>             --with-gd \
>             --with-zlib-dir="/usr" \
>             --with-png-dir="/usr/local" \
>             --with-jpeg-dir="/usr/local" \
 >            --enable-gd-native-ttf --with-freetype-dir=/usr \
 >            --with-mysql=/usr/sfw --enable-dbase \
 >            --with-libxml-dir=/usr/local \
>             --with-config-file-path=/etc/apache2

<snip>
creating libtool
appending configuration tag "CXX" to libtool

e[1mGenerating filese[m
creating ./config.status
creating php5.spec
creating main/build-defs.h
creating scripts/phpize
creating scripts/man1/phpize.1
creating scripts/php-config
creating scripts/man1/php-config.1
creating sapi/cli/php.1
creating main/php_config.h
main/php_config.h is unchanged
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

# 

Then I did "gmake / make" gives me the same result

# gmake
/bin/sh /php-5.1.4/libtool --silent --preserve-dup-deps --mode=compile gcc  -Iext/standard/ -I/php-5.1.4/ext/standard/ -DPHP_ATOM_INC -I/php-5.1.4/include -I/php-5.1.4/main -I/php-5.1.4 -I/usr/local/include/libxml2 -I/php-5.1.4/ext/date/lib -I/usr/local/include -I/usr/local/include/freetype2 -I/usr/sfw/include/mysql -I/php-5.1.4/TSRM -I/php-5.1.4/Zend  -D_POSIX_PTHREAD_SEMANTICS  -I/usr/local/include -g -O2   -c /php-5.1.4/ext/standard/info.c -o ext/standard/info.lo 
<snip>
Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_mm.lo Zend/zend_default_classes.lo Zend/zend_execute.lo sapi/cli/php_cli.lo sapi/cli/php_cli_readline.lo sapi/cli/getopt.lo main/internal_functions_cli.lo -lmysqlclient -lfreetype -lpng -lz -ljpeg -lz -lresolv -lm -lnsl -lsocket -lgcc -lxml2 -lz -lm -lsocket -lnsl -lxml2 -lz -lm -lsocket -lnsl -lxml2 -lz -lm -lsocket -lnsl -lxml2 -lz -lm -lsocket -lnsl -lxml2 -lz -lm -lsocket -lnsl -lxml2 -lz -lm -lsocket -lnsl  -o sapi/cli/php

Undefined                       first referenced
 symbol                             in file
libiconv_close                      ext/gd/libgd/.libs/gdkanji.o
libiconv_open                       ext/gd/libgd/.libs/gdkanji.o
libiconv                            ext/gd/libgd/.libs/gdkanji.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
gmake: *** [sapi/cli/php] Error 1
#
#

How do I get GD to work with my already compiled PHP ? Can someone please help me ? I have spent 2 complete days searching google and a lot of forums, but I've had just no luck.

I don't have any compulsion to use GD2 only, if someone knows how to get ImageMagick working, please do let me know, because I have tried to build it too using the install instructions for UNIX on their website, but got the following errors after I executed make (./configure for image magick was successful too)
snapshot of error from image magick installation

depbase=`echo Magick++/lib/Thread.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; \
if /bin/bash ./libtool --silent --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H  -I. -I. -I./magick -I./wand  -I. -I.  -I./Magick++/lib -I./Magick++/lib -I/usr/sfw/include/freetype2 -I/usr/sfw/include -I/usr/openwin/include -I/usr/openwin/include/X11 -I/usr/local/include/libxml2   -D_REENTRANT -pthread -MT Magick++/lib/Thread.lo -MD -MP -MF "$depbase.Tpo" -c -o Magick++/lib/Thread.lo Magick++/lib/Thread.cpp; \
then mv -f "$depbase.Tpo" "$depbase.Plo"; else rm -f "$depbase.Tpo"; exit 1; fi
g++: unrecognized option `-pthread'
depbase=`echo Magick++/lib/TypeMetric.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; \
if /bin/bash ./libtool --silent --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H  -I. -I. -I./magick -I./wand  -I. -I.  -I./Magick++/lib -I./Magick++/lib -I/usr/sfw/include/freetype2 -I/usr/sfw/include -I/usr/openwin/include -I/usr/openwin/include/X11 -I/usr/local/include/libxml2   -D_REENTRANT -pthread -MT Magick++/lib/TypeMetric.lo -MD -MP -MF "$depbase.Tpo" -c -o Magick++/lib/TypeMetric.lo Magick++/lib/TypeMetric.cpp; \
then mv -f "$depbase.Tpo" "$depbase.Plo"; else rm -f "$depbase.Tpo"; exit 1; fi
g++: unrecognized option `-pthread'
/bin/bash ./libtool --silent --tag=CXX --mode=link g++   -D_REENTRANT -pthread  -L/usr/openwin/lib -R/usr/openwin/lib -L/usr/sfw/lib -R/usr/sfw/lib -lfreetype -L/usr/local/lib -o Magick++/lib/libMagick++.la -rpath /usr/local/lib -version-info 10:4:0 Magick++/lib/Blob.lo  Magick++/lib/BlobRef.lo  Magick++/lib/CoderInfo.lo  Magick++/lib/Color.lo  Magick++/lib/Drawable.lo  Magick++/lib/Exception.lo  Magick++/lib/Functions.lo  Magick++/lib/Geometry.lo  Magick++/lib/Image.lo  Magick++/lib/ImageRef.lo  Magick++/lib/Montage.lo  Magick++/lib/Options.lo  Magick++/lib/Pixels.lo  Magick++/lib/STL.lo  Magick++/lib/Thread.lo  Magick++/lib/TypeMetric.lo magick/libMagick.la wand/libWand.la 
libtool: link: `/usr/sfw/lib/libstdc++.la' is not a valid libtool archive
*** Error code 1
make: Fatal error: Command failed for target `Magick++/lib/libMagick++.la'
# 
# 

sorry for the long post. I have attached my error log file for both GD and imagemagick.

Thanks
rohit

Some old objects may have left around. Try to run

gmake distclean

in your PHP build area first. Then rerun configure. Also enable --enable-iconv when you run configure, and make sure the "iconv" library exists on your system and be locatable by PHP.

Also, if you use any external GD installations instead of the bundled version, it may not necessarily work. Your mileage may vary. If everything fails, use the bundled version.

Hi,

Thanks for you reply.

Thats what I wanted to know, how to make PHP pick up the built in extension of GD as it didn't install it in the first go.....

second of all, do i need to run gmake distclean under /php-5.1.4. This folder is the main forlder with all the files which i downloaded from php.net.

cheers
rohit

hi cbkihong,

i tried what you suggested but got the same set of errors as last time.....

Undefined                       first referenced
 symbol                             in file
libiconv_close                      ext/gd/libgd/.libs/gdkanji.o
libiconv_open                       ext/gd/libgd/.libs/gdkanji.o
libiconv                            ext/gd/libgd/.libs/gdkanji.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
gmake: *** [sapi/cli/php] Error 1

Thanks
rohit

What about compiling with the bundled version of GD? You don't need to do anything. As GD is bundled, you just need to have the full PHP sources there, pass the "--with-gd" option to configure (or additional ones. Run "configure --help" for a list) then it should pick it up. Always remember to "gmake distclean". Forgetting to do so frequently causes mysterious compilation errors. You may need to remove your installed version of GD. It may probably cause problems.

I noticed from your logs that the linking command (that is failing) in the auto-generated Makefile does not include "-liconv", but your GD object apparently requires iconv, so there is this error. This probably indicates it is not compatible with PHP.

Are you sure GD is really not loaded in PHP? Did you restart your Apache? It should be linked into the PHP binary/libphp5.so instead of being a PHP extension.

I've modified the ./configure command to the following


./configure   --with-gd \
              --with-zlib-dir="/usr" \
              --with-png-dir="/usr/local" \
              --with-jpeg-dir="/usr/local" \
              --enable-gd-native-ttf --with-freetype-dir=/usr \
              --with-libxml-dir=/usr/local \
              --with-iconv-dir=/usr/local

Its running right now as we speak....I wanted to know, is there any change I would need to make in PHP.ini file. Also, when I run phpinfo on my server, I do see iconv listed as enabled and a few other parameters within it as enabled.

thanks
rohit

gmake is now running.

If this fails again, what options do i have. Is it possible to completely uninstall PHP from my sun box ? if so, how to do an uninstall. Secondly, I'll download
php-5.1.4.tar.gz again and to compile it with all the extenions what commands would I need to do. Because when I compiled it on my own, it left out GD and many more, it only installed a few.

Thanks
rohit

Got the same error again...please help me. Is it better to uninstall php completely and install it again with all extensions enabled........if so please let me know how to uninstall and install in a proper way.

thanks
rohit

Usually no. PHP can generally live well even when no configuration file is available, because all options have reasonable defaults.

If the PHP is installed from sources, you may try to simply remove the PHP/extension so and the CLI/CGI binary. I forgot whether the PHP makefile includes the "uninstall" target. If so, you may try to run "make uninstall". If you have removed the build workspace, you will not be able to uninstall this way.

If your PHP is provided by SUN or otherwise obtained in package format, read the manuals to find out how to do as I don't use SunOS myself.

You can't probably compile all extensions, as you may not have all prerequisites met. And I think there are no shortcuts. You need to specify each extension you would like to support as one or more configure option. Do not rely on auto-detection if possible. It frequently fails.

For iconv to work you also need to have libgcc installed. Hope this helps...