Compiling/Loading C function

From: Konstantinos Vassiliadis <vassilik(at)p05(dot)cs(dot)man(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Compiling/Loading C function
Date: 1998-07-22 12:43:06
Message-ID: Pine.LNX.3.95.980722133243.735B-100000@p05.cs.man.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello
I am desperately trying to use a type I have created. PostgreSQL runs
under SunOS 4.1.x. I followed the documentation's example on this platform
% cc -I$PGROOT/include -I$PGROOT/src/include -PIC -c phone.c
gives too many errors in header files...........

Then, I used gcc (following documentation's example for Solaris !!)
% gcc -I$PGROOT/include -I$PGROOT/src/include -fPIC -c phone.c
% ld -Bdynamic -o phone.so phone.o
Then from Linux client
% psql test
test=> CREATE FUNCTION phone_in(opaque)
RETURNS phone
AS '/home/postgres/linux/src/phone/phone.so'
LANGUAGE 'c';

CREATE FUNCTION phone_out(opaque)
RETURNS opaque
AS '/home/postgres/linux/src/phone/phone.so'
LANGUAGE 'c';

CREATE TYPE phone (
internallength =8,
input = phone_in,
output = phone_out);

CREATE TABLE test_phone (
mynumber phone,
hernumber phone);

INSERT INTO test_phone VALUES ('01483-827294','0161-2242394');

At this point gives
ERROR: Load of file /home/postgres/linux/src/phone/phone.so failed:
ld.so: object could not be mapped
I then issue 'load' from prompt:
test=> load '/home/postgres/linux/src/phone/phone.so';
ERROR: LOAD: could not open file /home/postgres/linux/src/phone/phone.so

Therefore I desperately ask:

a) Do I compile for the platform where Postgres runs? (may sound ignorant
but in fact it is my first real exposure to C compilers)

b) Do I use cc or gcc?

c) Could the options used in the compilation/linking process differ among
two cases even though Postgres runs on same plarform?

d) Do I need to use 'load' or is the function automatically loaded when
first called?

Thanks
Kostas

Browse pgsql-general by date

  From Date Subject
Next Message The Hermit Hacker 1998-07-22 12:47:27 Re: [GENERAL] Re: [HACKERS] [Fwd: SGVLLUG Oracle and Informix on Linux]
Previous Message The Hermit Hacker 1998-07-22 12:22:37 Re: [GENERAL] Re: [HACKERS] [Fwd: SGVLLUG Oracle and Informix on Linux]