Réf. : [postgis-users] Creating a C spi function that calls Postgis functions

bsimon at loxane.com bsimon at loxane.com
Thu Feb 26 02:25:56 PST 2004


As I don't get any answers, I think you may need more information on my 
problem ;-) :

I'd like to get the X coordinate for a each point of a linestring :

Here is a part of my code :

        geom = (GEOMETRY *)PG_DETOAST_DATUM(datum);
 
        offsets = (int32 *) ( ((char *) &(geom->objType[0] ))+ 
sizeof(int32) * geom->nobjs ) ;
 
                        for (k=0; k< geom->nobjs; k++) 
                        {
                                o = (char *) geom + offsets[k] ;
                                type =  geom->objType[k];
 
                                if (type == LINETYPE)
                                {
                                    line = (LINE3D *)o;
 
                                    for(l=0;l<coord.NbCoord;l++){
 
                                        point.x = 
DatumGetFloat8(x_point((GEOMETRY *) make_oneobj_geometry(sizeof(POINT3D),
  (char *)&line->points[k+1],
      POINTTYPE, 
      geom->is3d, 
      geom->SRID, 
      geom->scale, 
      geom->offsetX, 
      geom->offsetY)));
                                }
                                }
                        }



Here is how I compile my code :

gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes 
-Wmissing-declarations -I/usr/src/postgresql-7.4.1-3/src/include  -c -o 
MyFunc.o MyFunc.c
dlltool --export-all --output-def MyFunc.def MyFunc.o
dllwrap -o gdf2ToGdf1.dll --dllname MyFunc.dll \
--def MyFunc.def MyFunc.o \
/usr/src/postgresql-7.4.1-3/src/utils/dllinit.o \
-L/usr/src/postgresql-7.4.1-3/contrib/postgis-0.8.1/ -lpostgis \
-L/usr/src/postgresql-7.4.1-3/src/backend -lpostgres \

Here is how I create the function :

CREATE FUNCTION MyFunc() RETURNS integer
      AS '/home/bsimon/functions/MyFunc'
      LANGUAGE 'c';

Here is the error I get :

ERROR:  could not load library "/home/bsimon/functions/MyFunc.dll": 
dlopen: Win32 error 126 


I hope this could help !!!
Thanks.
B.S.






bsimon at loxane.com
Envoyé par : postgis-users-bounces at postgis.refractions.net
25/02/2004 11:45
Veuillez répondre à PostGIS Users Discussion

 
        Pour :  postgis-users at postgis.refractions.net
        cc : 
        Objet : [postgis-users] Creating a C spi function that calls Postgis    functions



Hi, 

I 've written a C spi function that connects to a base, retrieves some 
geometries and does some proccessing on them. Everything is Ok so far. 
The problem occurs when in my processing algorithm I try to use some 
Postgis functions (such as "x_point" or "make_oneobj_geometry"). I manage 
to link my code with postgis export library but I can't figure out why my 
CREATE FUNCTION statement fails ! 

here is the error I get when I try to create the function : 

ERROR:  could not load library "/home/bsimon/functions/MyFunc.dll": 
dlopen: Win32 error 126   (I use cygwin) 

Any ideas ?? 

B.S 
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20040226/8d8dccfc/attachment.html>


More information about the postgis-users mailing list