Problem with make libpgosm.so

Hiya trying to get the ruby port working with PostgreSQL on Leopard but I’ve run into a problem when compiling libpgosm.so

Anyone got any ideas?

Cheers

Alex

I’m having the same problem, i’ve followed it to line 61 of quadtile.c, but am a bit lost there.

Please share if you figure it out!

OK, I followed these steps:

I looked for the tile_for_point() function, and it was on line 56 of quadtile.c:

Datum
tile_for_point(PG_FUNCTION_ARGS)
{
double lat = PG_GETARG_INT32(0) / 10000000.0;
double lon = PG_GETARG_INT32(1) / 10000000.0;

PG_RETURN_INT64(xy2tile(lon2x(lon), lat2y(lat)));
}

Apparently in the source of PostgreSQL I found PG_RETURN_INT64:

/src/include/fmgr.h line 290

#define PG_RETURN_INT64(x) return Int64GetDatum(x)

so, looking for Int64GetDatum…

Int64GetDatum is externally defined, line 545 of /src/include/postgres.h:

extern Datum Int64GetDatum(int64 X);

But there’s an alternative Int64GetDatumFast() at line 645 of postgres.h:

#define Int64GetDatumFast(X) PointerGetDatum(&(X))

Anyways, on line 61 i switched PG_RETURN_INT64() for PointerGetDatum():

61:PointerGetDatum(xy2tile(lon2x(lon), lat2y(lat)));

Then, finally i could run “make libpgosm.so”.

Then I ran the CREATE FUNCTION in postgresql:

CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4
AS ‘/Users/eco/Sites/openstreetmap/db/functions/libpgosm’, ‘maptile_for_point’
LANGUAGE C STRICT;

Unfortunately I got back:

ERROR: could not load library “/Users/eco/Sites/openstreetmap/db/functions/libpgosm.so”: dlopen(/Users/eco/Sites/openstreetmap/db/functions/libpgosm.so, 10): no suitable image found. Did find:
/Users/eco/Sites/openstreetmap/db/functions/libpgosm.so: mach-o, but wrong architecture

********** Error **********

ERROR: could not load library “/Users/eco/Sites/openstreetmap/db/functions/libpgosm.so”: dlopen(/Users/eco/Sites/openstreetmap/db/functions/libpgosm.so, 10): no suitable image found. Did find:
/Users/eco/Sites/openstreetmap/db/functions/libpgosm.so: mach-o, but wrong architecture
SQL state: 58P01

Weird, huh? I’m not sure how to proceed from here.