Problems compiling a trigger

Started by Rodolfo Camposalmost 20 years ago2 messages
#1Rodolfo Campos
camposer@gmail.com

Hi fellows,

I'm getting problems compiling a trigger written in C (exactly the one from
the documentation), when compiling it I get the errore shwoned here.

I think the problem might be the linker, but I don't know how to fix it.

The command that I run was:

gcc -I /usr/include/postgresql/server prueba1.c

And here is the error:

/usr/lib/gcc-lib/i486-linux/3.3.5/../../../crt1.o(.text+0x18): En la función
`_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
/tmp/cc4DCNL5.o(.text+0x56): En la función `trigf':
: undefined reference to `errstart'
/tmp/cc4DCNL5.o(.text+0x6a): En la función `trigf':
: undefined reference to `elog_finish'
/tmp/cc4DCNL5.o(.text+0xd9): En la función `trigf':
: undefined reference to `SPI_connect'
/tmp/cc4DCNL5.o(.text+0x106): En la función `trigf':
: undefined reference to `errstart'
/tmp/cc4DCNL5.o(.text+0x128): En la función `trigf':
: undefined reference to `elog_finish'
/tmp/cc4DCNL5.o(.text+0x13c): En la función `trigf':
: undefined reference to `SPI_exec'
/tmp/cc4DCNL5.o(.text+0x169): En la función `trigf':
: undefined reference to `errstart'
/tmp/cc4DCNL5.o(.text+0x18b): En la función `trigf':
: undefined reference to `elog_finish'
/tmp/cc4DCNL5.o(.text+0x19f): En la función `trigf':
: undefined reference to `SPI_tuptable'
/tmp/cc4DCNL5.o(.text+0x1ab): En la función `trigf':
: undefined reference to `SPI_tuptable'
/tmp/cc4DCNL5.o(.text+0x1b8): En la función `trigf':
: undefined reference to `SPI_getbinval'
/tmp/cc4DCNL5.o(.text+0x1e1): En la función `trigf':
: undefined reference to `errstart'
/tmp/cc4DCNL5.o(.text+0x203): En la función `trigf':
: undefined reference to `elog_finish'
/tmp/cc4DCNL5.o(.text+0x208): En la función `trigf':
: undefined reference to `SPI_finish'
/tmp/cc4DCNL5.o(.text+0x22f): En la función `trigf':
: undefined reference to `SPI_getbinval'
collect2: ld devolvió el estado de salida 1

I'm running Debian-Sarge and I have postgresql, postgresql-dev,
postgresq-contrib packakes with gcc3.3, gcc3.3-base and libc6 installed on
my machine.

Any help that you can bring to me should be very helpfuly. Thanks in
advance,

Rodolfo.

#2Neil Conway
neilc@samurai.com
In reply to: Rodolfo Campos (#1)
Re: Problems compiling a trigger

On Tue, 2006-02-07 at 19:45 -0400, Rodolfo Campos wrote:

I'm getting problems compiling a trigger written in C (exactly the one
from the documentation), when compiling it I get the errore shwoned
here.

This question belongs elsewhere (e.g. pgsql-general) -- -hackers is for
development-related discussion.

gcc -I /usr/include/postgresql/server prueba1.c

Read:

http://www.postgresql.org/docs/8.1/static/xfunc-c.html#DFUNC

which tells you to do:

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

-Neil