Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group