[gdal-dev] Re: PHP bindings

Mike Leahy mgleahy at alumni.uwaterloo.ca
Wed Feb 9 02:47:25 EST 2011


Hi Tamas,

Thanks for the feedback.  I've tried what you suggested, regenerating the swig 
bindings, and setting the LD_LIBRARY_PATH...though the outcome seems to be the 
same.  Here's my output from manually building php_gdal.so, from within the 
swig/php source directory:

==============================
swig -Wall -I../include -I../include/php -I../include/php/docs  \
-I/sources/gdal/gdal-1.8.0 -c++ -php -o gdal_wrap.cpp ../include/gdal.i

../include/ColorTable.i:60: Warning(314): 'clone' is a PHP keyword, renamed as 
'c_clone'
../include/RasterAttributeTable.i:92: Warning(314): 'clone' is a PHP keyword, 
renamed as 'c_clone'
../include/gdal.i:206: Warning(453): Can't apply (Pointer NONNULL). No 
typemaps are defined.
../include/cpl.i:228: Warning(453): Can't apply (char **CSL). No typemaps are 
defined.
../include/Dataset.i:474: Warning(453): Can't apply (char **CSL). No typemaps 
are defined.
../include/Band.i:289: Warning(453): Can't apply (IF_ERROR_RETURN_NONE). No 
typemaps are defined.
../include/Band.i:303: Warning(453): Can't apply (IF_ERROR_RETURN_NONE). No 
typemaps are defined.
../include/Operations.i:229: Warning(453): Can't apply (int nList,double 
*pList). No typemaps are defined.
../include/Operations.i:360: Warning(453): Can't apply (int 
object_list_count,GDALRasterBandShadow **poObjects). No typemaps are defined.
../include/Operations.i:474: Warning(453): Can't apply (int nList,double 
*pList). No typemaps are defined.

g++ -I../../port -I../../gcore -I../../alg -I../../ogr `php-config \
--includes` -fpic -c gdal_wrap.cpp

gcc -shared gdal_wrap.o -o php_gdal.so
==============================

At this point, I've got a php_gdal.so file, which will not load in PHP.  I 
think for whatever reason, the module is not linking to the gdal core library. 
So either LD_LIBRARY_PATH has no effect, or there's something else that's being 
missed. Here's the output from ldd:

ldd php_gdal.so
        linux-vdso.so.1 =>  (0x00007fff9b985000)
        libc.so.6 => /lib/libc.so.6 (0x00007f0a329cc000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0a32fce000)

I can successfully build /and/ load php_osr.so, but when I create an osr 
object in a sample PHP script, all of the object's methods return an integer 
zero, instead of the expected output (e.g., importing/exporting projection 
text).

There are less warnings when generating the swig bindings for osr_wrap.cpp 
(just three, similar to the 'clone' and 'CSL' related warnings above).  Also, 
when I run the g++ command above for osr, I see lots of warnings, such as:

==============================
osr_wrap.cpp: In function ‘char* OGRErrMessages(int)’:
osr_wrap.cpp:1169: warning: deprecated conversion from string constant to 
‘char*’
osr_wrap.cpp:1171: warning: deprecated conversion from string constant to 
‘char*’
osr_wrap.cpp:1173: warning: deprecated conversion from string constant to 
‘char*’

....

osr_wrap.cpp: In function ‘int zm_startup_osr(int, int)’:
osr_wrap.cpp:8255: warning: deprecated conversion from string constant to 
‘char*’
osr_wrap.cpp:8256: warning: deprecated conversion from string constant to 
‘char*’

...
==============================

At this point, there's not much more I can do to without some guidance from 
someone with a better understanding of where things could be going wrong.  Is 
this perhaps a topic that would be better discussed with the SWIG users list?

Best regards,
Mike

On Tuesday, February 08, 2011 15:44:54 Tamas Szekeres wrote:
> Mike,
> 
> Actually the PHP bindings are not maintained at all, so any improvements in
> this topic would be welcomed. You might also want to regenerate the
> bindings with SWIG since the committed version may be outdated. You should
> also make sure the corresponding gdal core is available load (proably by
> setting LD_LIBRARY_PATH).
> 
> Best regards,
> 
> Tamas
> 
> 
> 
> 2011/2/8 Mike Leahy <mgleahy at alumni.uwaterloo.ca>
> 
> >  Hi again,
> > 
> > I recognize this perhaps isn't a popular topic. However, I thought I'd
> > give the PHP bingings a try with the latest 1.8.0 release. It's somewhat
> > promising to see that enabling the php bindings in the ./configure
> > options and compiling will succesfully produce a php_gdal.so library.
> > After finding this, I ran make install for gdal, then copied the
> > php_gdal.so to the PHP modules folder and configured PHP to load it.
> > Unfortunately, I get the following output in the Apache error logs when
> > I attempt to load the module in PHP:
> > 
> > PHP Warning: PHP Startup: Unable to load dynamic library
> > '/usr/lib/php5/20090626+lfs/php_gdal.so' -
> > /usr/lib/php5/20090626+lfs/php_gdal.so: undefined symbol:
> > CPLLoggingErrorHandler in Unknown on line 0
> > 
> > I'm not really sure where to look next. Could it be a compatibility issue
> > with PHP 5.3.3, or maybe for some reason the php module isn't able to
> > access the installed gdal libraries?
> > 
> > Any suggestions would be welcome. I'm testing this in a minimal 64-bit
> > Ubuntu 10.11 VM.
> > 
> > Regards,
> > 
> > Mike
> > 
> > On Sunday, February 06, 2011 14:50:34 Mike Leahy wrote:
> > > Hello List,
> > > 
> > > 
> > > 
> > > Does anyone have an idea if there is any likelihood for a revival of
> > > php
> > > 
> > > bindings for GDAL/OGR. I know if these were available, I'd be making
> > > use
> > > 
> > > of them...although, I have no experience creating/maintaining SWIG
> > > 
> > > libraries. So I'm curious to know what someone would need to know to
> > > get
> > > 
> > > started on this, and how big of a job would it likely be?
> > > 
> > > 
> > > 
> > > Regards,
> > > 
> > > Mike
> > 
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110209/29f056aa/attachment-0001.html


More information about the gdal-dev mailing list