From: | José Paumard <Jose(dot)Paumard(at)cmla(dot)ens-cachan(dot)fr> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Creating a function from C code |
Date: | 1998-12-04 15:59:09 |
Message-ID: | 366806CD.66188B64@cmla.ens-cachan.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello everybody,
I am trying to understand how to create functions written in C available
in postgres. I tried to carefully follow the example provided in the
Programmer's guide, given with the 6.4 distribution.
So :
1) I typed the add_one example :
#include "postgres.h"
int4
add_one(int4 arg)
{
return(arg + 1) ;
/* that one is complex enough for me ! */
}
and compiled it with a :
$ gcc add_one.c -c -o add_one.o -I/usr/local/pgsql/include
and linked it with a :
$ ld -Bshareable -o add_one.so add_one.o -lpq -L/usr/local/pgsql/lib
and everything ran fine
2) I had the user postgres put the add_one.so file in
/usr/local/pgsql/lib :
-rwxr-xr-x 1 postgres postgres 2465 Dec 4 16:51 add_one.so
3) I launched postgres with the command :
$ psql template1
and then :
template1=> create function add_one(int4) returns int4 as
'/usr/local/pgsql/lib/add_one.so' language 'c' ;
ERROR: Can't find function add_one in file
/usr/local/pgsql/lib/essai.so
gr(at)!#$*(dot)h|?mph
The Programmer's guide says that there are explainations in the Appendix
A about the options needed by the linker to generate code understandable
by Postgres. I did not find any. I tried to look at the makfiles in the
contrib directory of the distribution, and cant find what I am doing
wrong.
Any help would be much appreciated, could you answer me to my personnal
adress, if I solve this problem, I will make a summary in this forum.
Thank you again,
Jose Paumard
Jose(dot)Paumard(at)cmla(dot)ens-cachan(dot)fr
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1998-12-04 16:17:21 | Re: [GENERAL] Generic search |
Previous Message | Sferacarta Software | 1998-12-04 15:30:35 | Re[2]: [GENERAL] Generic search |