Problem running C function

From: "Luca Carrettin" <lucacarrettin(at)sogeasoft(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Problem running C function
Date: 2001-10-24 16:30:34
Message-ID: HNEHLEADNHCKABLPOHLEOEAICAAA.lucacarrettin@sogeasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm trying to compile and run my first C function on server side.
I considered this simple example from the programmer's guide:

#include "postgres.h"
#include "fmgr.h"

PG_FUNCTION_INFO_V1(add_one);

Datum
add_one(PG_FUNCTION_ARGS)
{
int32 arg = PG_GETARG_INT32(0);
PG_RETURN_INT32(arg + 1);
}

I compiled the file libtest.c containing this code and generated libtest.so
on a Linux machine by the following commands:

cc -fpic -c libtest.c
cc -shared -o libtest.so libtest.o

Then I registered the function add_one like said in the programmer's guide:

CREATE FUNCTION add_one(int4) RETURNS int4
AS ’.../libtest.so’ LANGUAGE ’c’
WITH (isStrict);

Now, when executing
SELECT add_one(10);
I get the following message:
ERROR: Load of file .../libtest.so failed: undefined symbol: PG_GETARG_INT32

Can somebody help me?
Thanks.
Luca.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-10-24 18:59:58 Re: Problem running C function
Previous Message Daniel Bautista 2001-10-24 13:29:24 current and beta versions