Re: Compiling a user C function in 7.2.1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Gunther <inbox(at)bucksvsbytes(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Compiling a user C function in 7.2.1
Date: 2002-07-28 17:12:45
Message-ID: 11547.1027876365@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

John Gunther <inbox(at)bucksvsbytes(dot)com> writes:
> Now I'm much further along: I have created a dynamic library
> (bvbpglib.so) containing one PostgreSQL C function (bvbpgsortword). This
> function calls a "regular" (non-PostgreSQL) C function (bvbmakesortstring).

> My current problem is that my psql statement:
> CREATE FUNCTION bvbpgsortword(TEXT) RETURNS TEXT AS
> '/usr/include/bvbpglib' LANGUAGE C WITH (ISSTRICT);
> fails with "undefined symbol: bvbmakesortstring"

> This is probably the result of some fundamental deficit in my
> understanding of C writing/compiling/linking, but what puzzles me is
> that bvbmakesortstring is called successfully from another C program I
> wrote. Only in psql does it come back undefined.

You have to make sure that the dynamic linker knows where to find the
library that contains bvbmakesortstring --- when one .so file depends
on another, the first one needs to be explicitly marked that way.

I think it would work to mention the other .so file as a library in
the link command for bvbpglib.so.

Try "ldd" on bvbpglib.so to see which libraries it's marked as needing,
and whether the dynamic linker knows where to find them.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message John Gunther 2002-07-28 18:28:56 Re: Compiling a user C function in 7.2.1
Previous Message John Gunther 2002-07-28 12:36:39 Re: Compiling a user C function in 7.2.1