Problem running C function - Mailing list pgsql-novice

From Luca Carrettin
Subject Problem running C function
Date
Msg-id HNEHLEADNHCKABLPOHLEOEAICAAA.lucacarrettin@sogeasoft.com
Whole thread Raw
Responses Re: Problem running C function
List 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.


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: column length?
Next
From: Daniel Bautista
Date:
Subject: current and beta versions