Thread: Problems compiling a trigger

Problems compiling a trigger

From
Rodolfo Campos
Date:
Hi fellows,<br /><br /> I'm getting problems compiling a trigger written in C (exactly the one from the documentation),
whencompiling it I get the errore shwoned here.<br /><br /> I think the problem might be the linker, but I don't know
howto fix it.<br /><br /> The command that I run was:<br /><br /> gcc -I /usr/include/postgresql/server prueba1.c<br
/><br/> And here is the error:<br /><br /> /usr/lib/gcc-lib/i486-linux/3.3.5/../../../crt1.o(.text+0x18): En la función
`_start':<br/> ../sysdeps/i386/elf/start.S:115: undefined reference to `main'<br /> /tmp/cc4DCNL5.o(.text+0x56): En la
función`trigf':<br /> : undefined reference to `errstart'<br /> /tmp/cc4DCNL5.o(.text+0x6a): En la función `trigf':<br
/>: undefined reference to `elog_finish'<br /> /tmp/cc4DCNL5.o(.text+0xd9): En la función `trigf':<br /> : undefined
referenceto `SPI_connect'<br /> /tmp/cc4DCNL5.o(.text+0x106): En la función `trigf':<br /> : undefined reference to
`errstart'<br/> /tmp/cc4DCNL5.o(.text+0x128): En la función `trigf':<br /> : undefined reference to `elog_finish'<br />
/tmp/cc4DCNL5.o(.text+0x13c):En la función `trigf':<br /> : undefined reference to `SPI_exec'<br />
/tmp/cc4DCNL5.o(.text+0x169):En la función `trigf':<br /> : undefined reference to `errstart'<br />
/tmp/cc4DCNL5.o(.text+0x18b):En la función `trigf':<br /> : undefined reference to `elog_finish'<br />
/tmp/cc4DCNL5.o(.text+0x19f):En la función `trigf':<br /> : undefined reference to `SPI_tuptable'<br />
/tmp/cc4DCNL5.o(.text+0x1ab):En la función `trigf':<br /> : undefined reference to `SPI_tuptable'<br />
/tmp/cc4DCNL5.o(.text+0x1b8):En la función `trigf':<br /> : undefined reference to `SPI_getbinval'<br />
/tmp/cc4DCNL5.o(.text+0x1e1):En la función `trigf':<br /> : undefined reference to `errstart'<br />
/tmp/cc4DCNL5.o(.text+0x203):En la función `trigf':<br /> : undefined reference to `elog_finish'<br />
/tmp/cc4DCNL5.o(.text+0x208):En la función `trigf':<br /> : undefined reference to `SPI_finish'<br />
/tmp/cc4DCNL5.o(.text+0x22f):En la función `trigf':<br /> : undefined reference to `SPI_getbinval'<br /> collect2: ld
devolvióel estado de salida 1<br /><br /> I'm running Debian-Sarge and I have postgresql, postgresql-dev,
postgresq-contribpackakes with gcc3.3, gcc3.3-base and libc6 installed on my machine.<br /><br /> Any help that you can
bringto me should be very helpfuly. Thanks in advance,<br /><br /> Rodolfo.<br /> 

Re: Problems compiling a trigger

From
Neil Conway
Date:
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