Building SPI programs

From: Aristide Aragon <zuri(at)busa(dot)lionking(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Building SPI programs
Date: 2001-02-17 19:27:18
Message-ID: 20010217132718.C14720@busa.lionking.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello
I have to do some programming in C or C++ and PostgreSQL.
Having not ever done this before, I opened the documentation (in my machine, /usr/local/pgsql/doc) and read about the options I had. SPI, libpq, libpq++ and ecpg. I don't want, if possible, an embeded language, or anything that requires a preprocessor. So, I thought to start by trying the first, SPI, which also seemed to be simple.
My problem comes when compiling, since the documentation doesn't say where the include files are, nor what libraries to compile against.
So, I found out about the include dirs required (amazingly, one was in the source directory tree, and was not copied to usr/local/pgsql/include when I installed PGSQL), and ended with cc -I/busa/tmp/postgresql-7.0.2/src/include/ -I/usr/local/pgsql/include test.c -o test
With this command line, I got

/tmp/ccPIp24d.o: In function `main':
/tmp/ccPIp24d.o(.text+0x7): undefined reference to `SPI_connect'
/tmp/ccPIp24d.o(.text+0x2b): undefined reference to `SPI_exec'
/tmp/ccPIp24d.o(.text+0x33): undefined reference to `SPI_finish'

So I supposed I needed to link against some library. With grep I searched /usr/local/pgsql/lib for SPI_, and I found no .a's matching.
I found that /usr/local/pgsql/lib/plpgsql.so and /usr/local/pgsql/lib/pltcl.so had "SPI_", however none worked.

So, can somebody help me compile a C program with SPI?

Thanks

Aristide

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matt Friedman 2001-02-17 19:42:37 Re: SELECT (sometimes) returning Zero Rows? Fixed, sort of...
Previous Message David Wheeler 2001-02-17 18:50:31 Re: Case insensitive selects?