I'm trying to get a feel for creating a function in C, but am encountering a problem. I'm working on Solaris, and according to 'pg_config --version' am working with a Postgres 8.1.18 database. 'pg_config --includedir' gives me /usr/include/pgsql.

If I set my -I flags to that directory and it server subdirectory I am able to compile a simple c file into a .so. However when I try to 'create or replace function' using that .so I get an error that it is missing a magic block. I tried to include:

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

in the .c file, but it didn't help. grep of that directory finds no files that contain PG_MODULE_MAGIC.

I did find /usr/postgres/8.2/include and /usr/postgres/8.3/include directories though, and tried compiling against them. Using 8.2, when I create the function I get an "incompatible library" magic block mismatch error. But if I compile against 8.3 the error states "Server: 8.2, Library: 8.3".

I am really at a loss how to resolve this problem. Can anyone recommend a solution?

Thanks,
Dave D