Triggers - Mailing list pgsql-cygwin

From Alan Clucas
Subject Triggers
Date
Msg-id 3E55F0EA.4@pipstechnology.co.uk
Whole thread Raw
Responses Re: Triggers
List pgsql-cygwin
I am trying to create a simple trigger for postgres under cygwin in C. I
have followed the examples but I still can't get anything to load.

I am using current cygwin compiled postgresql with the sources installed
for their headerfiles, under Windows XP with SP1 (not that it should
matter). Postgresql thinks it's version 7.3.1-1.

Trying to compile one of the demonstration files (refint) in
C:\cygwin\usr\src\postgresql-7.3.1-1\contrib\spi\

postgres@alanc-xp /usr/src/postgresql-7.3.1-1/contrib/spi
$ gcc -I../../src/include -I../../src/backend   -O2 -Wall
-Wmissing-prototypes -O6 -fpic -I../../src/include   -c refint.c -o refint.o
cc1: warning: -fpic ignored for target (all code is position independent)

postgres@alanc-xp /usr/src/postgresql-7.3.1-1/contrib/spi
$ gcc -shared -o refint.so refint.o
refint.o(.text+0x302):refint.c: undefined reference to `_elog'
refint.o(.text+0x363):refint.c: undefined reference to `_elog'
refint.o(.text+0x389):refint.c: undefined reference to `_SPI_connect'
<SNIP - lots and lots of missing references>

As far as I can gather the undefined references shouldn't be resolved at
this point, instead they are resolved when the object is loaded into
postgres. So I have also tried loading the .o (unlinked files) to which
I get

jtms=# CREATE FUNCTION check_primary_key() RETURNS TRIGGER AS
'/usr/src/postgresql-7.3.1-1/contrib/spi/refint.o' LANGUAGE C;
ERROR:  Load of file /usr/src/postgresql-7.3.1-1/contrib/spi/refint.o
failed: dlopen: Win32 error 193

I presume this is because refint.o isn't a libary, so this is just me
being silly. I'm really stuck now, and the search engines are fed up
with me trying to find the answer.

Oh - and:

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /netrel/src/gcc-3.2-3/configure
--enable-languages=c,c++,f77,ja
va --enable-libgcj --enable-threads=posix --with-system-zlib
--enable-nls --with
out-included-gettext --enable-interpreter --disable-sjlj-exceptions
--disable-ve
rsion-specific-runtime-libs --enable-shared --build=i686-pc-linux
--host=i686-pc
-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr
--exec-prefix=/usr
--sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include
--libexecd
ir=/usr/sbin
Thread model: posix
gcc version 3.2 20020927 (prerelease)

I have also tried with gcc2.95 of some variant or other. The above
procedure works fine under linux.

Any help gratefully received.

Alan


pgsql-cygwin by date:

Previous
From: "Gerrit P. Haase"
Date:
Subject: Re: How to set up postgres in WIN98?
Next
From: "erwan ancel"
Date:
Subject: pq mingw version