Cygwin and C triggers

From: Alan Clucas <alanc(at)pipstechnology(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Cygwin and C triggers
Date: 2003-02-13 12:27:36
Message-ID: 3E4B8F38.5050101@pipstechnology.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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(at)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(at)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)

Any help gratefully received.

Alan

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message HK 2003-02-13 13:59:25 accessing primary key slower than accessing non primary key???
Previous Message guillermo schulman 2003-02-13 12:20:13 Backup method and vacuumdb