compiling extension functions? (fwd)

From: Tripp Lilley <tlilley(at)perspex(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: compiling extension functions? (fwd)
Date: 1998-02-11 19:41:22
Message-ID: Pine.LNX.3.95.980211144035.32115Y-100000@mail.perspex.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I posted this to questions a few days back but got no response. Can anyone
here help me with this? I know it should be straightforward, and that I'm
missing something obvious, but precisely *what* I'm missing is unknown to
me.

Thanks!

- t.

-----------------------------------------------------------------------
Tripp Lilley, Perspex Imageworks, Inc. (tripp(dot)lilley(at)perspex(dot)com)
-----------------------------------------------------------------------
"Give me a fast computer, for I intend to go in harm's way"
- updating John Paul Jones

---------- Forwarded message ----------
Date: Mon, 9 Feb 1998 12:42:48 -0500 (EST)
From: Tripp Lilley <tlilley(at)perspex(dot)com>
To: pgsql-questions(at)postgresql(dot)org
Subject: compiling extension functions?

I'm trying to compile and use a 'C' extension function for PG 6.2.1 under
Red Hat Linux 4.2 (stock distribution). I am executing the following
commands to compile my shared library and install my function, but I get
"Unable to resolve symbol" when I try to execute the function.

> gcc -fpic -shared salmon.c -o salmon.so -L/usr/lib -lpq
-I/usr/include/postgres
> touch salmon.sql
> psql -d nim_0_01 -f salmon.sql
drop function salmon (int4);
DROP

create function
salmon (int4)
returns
char16
as
'/home/tlilley/projects/perspex/scratch/nim/salmon.so'
language
'c';
CREATE
EOF

> psql -d nim_0_01

nim_0_01=> select salmon( 42 );
WARN:Load of file /home/tlilley/projects/perspex/scratch/nim/salmon.so
failed: Unable to resolve symbol
nim_0_01=>

And here's the source for my function:

#include <postgres.h>
#include <utils/palloc.h>

char16 * salmon (int4 value)
{
char16 * buffer = (char16 *) palloc( sizeof( char16 ) );

memset( (void *) buffer, 0, sizeof( char16 ) );
(void) strncpy( buffer, "hello", 16 );
return( buffer );
}

Any help (especially 'working' compile command-lines) would be great!

Thanks...

- t.

-----------------------------------------------------------------------
Tripp Lilley, Perspex Imageworks, Inc. (tripp(dot)lilley(at)perspex(dot)com)
-----------------------------------------------------------------------
"Give me a fast computer, for I intend to go in harm's way"
- updating John Paul Jones

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1998-02-11 19:50:59 Re: [HACKERS] PostGreSQL v6.2.1 for Linux Alpha
Previous Message Kent S. Gordon 1998-02-11 19:27:54 Re: [HACKERS] Re: [QUESTIONS] Error on PostgreSQL agregate SUM() function??