pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedCompiling a function
4+ messages / 3 participants
[nested] [flat]
* Compiling a function
@ 1999-04-20 06:41 Matthew Hagerty <matthew@venux.net>
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Hagerty @ 1999-04-20 06:41 UTC (permalink / raw)
To: pgsql-interfaces
Greetings,
I have a very simple function I am trying to get working with 6.2.4. I
compiled the C program without any errors, but when I try to do a simple
query to see if it worked I get this error:
select bool2int(1 > 1);
ERROR: Load of file /usr/local/pgsql/procs/bool2int.o failed: dlopen
(/usr/local/pgsql/procs/bool2int.o) failed
I am running on FreeBSD-3.1-RELEASE with GCC 2.7.2.1. The command I issued
to compile was:
gcc -fpic -I../include -c bool2int.c
and the program is:
#include "../include/postgres.h"
int2 bool2int(bCondition)
bool bCondition;
{
if (bCondition)
return(1);
else
return(0);
}
I must say thank you to Jose Soares for providing me a solution, i.e. this
function, however I cannot get it to work.
Thanks,
Matthew Hagerty
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] Compiling a function
@ 1999-04-20 08:19 Matthew Hagerty <matthew@venux.net>
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Hagerty @ 1999-04-20 08:19 UTC (permalink / raw)
To: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>; +Cc: pgsql-interfaces
At 01:55 AM 4/20/99 -0400, you wrote:
>> ERROR: Load of file /usr/local/pgsql/procs/bool2int.o failed: dlopen
>> (/usr/local/pgsql/procs/bool2int.o) failed
>
>3 points:
>
>Make sure /usr/local/pgsql/procs/bool2int.o exists and is accessible to
>postgres
>
>Even though you are running FreeBSD, I believe you need to build a shared
>object (bool2int.so), not just an object file
>
>Start with examples in src/tutorial/. Watch what their Makefile is doing.
>
>
>--Gene
Thanks! I linked with -shared and that fixed the LOAD problem. Now I get
an error saying the function cannot be found in the file...
ERROR: Can't find function bool2int in file /usr/local/pgsql/procs/bool2int.o
I have tried every linker flag possible, nothing helps. Seems funny that a
function cannot be located in a library file?!?!
Any *more* insight whould be greatly appreciated.
Thanks,
Matthew
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] Compiling a function
@ 1999-04-20 12:58 Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
parent: Matthew Hagerty <matthew@venux.net>
0 siblings, 1 reply; 4+ messages in thread
From: Gene Selkov, Jr. @ 1999-04-20 12:58 UTC (permalink / raw)
To: Matthew Hagerty <matthew@venux.net>; pgsql-interfaces
> ERROR: Can't find function bool2int in file /usr/local/pgsql/procs/bool2int.o
>
That's probably because you are still looking in the object file. If
you did not tweak the filenames, the linker should create a shared
object file with the .so suffix, and it's likely that it did. Use
'file' to find out, like this (real example):
file /home/wit/pgsql/ExtendedTypes/seg/seg.o
/home/wit/pgsql/ExtendedTypes/seg/seg.o: ELF 32-bit LSB relocatable, Intel 80386, version 1, not stripped
file /home/wit/pgsql/ExtendedTypes/seg/seg.so
/home/wit/pgsql/ExtendedTypes/seg/seg.so: ELF 32-bit LSB shared object, Intel 80386, version 1, not stripped
> I have tried every linker flag possible, nothing helps. Seems funny that a
> function cannot be located in a library file?!?!
Object files and shared libraries have different symbol tables, let
alone the code.
I remember building things painlessly in FreeBSD, but that was a
couple years back, so I am not sure now. In any event, I would start
with tutorial examples because these are almost guaranteed to
work. Also, here's a complete code for a user-defined function -- you
will only need to adjust the paths in the Makefile and in the sql
script:
http://wit.mcs.anl.gov/~selkovjr/foldit.tgz
--Gene
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] Compiling a function
@ 1999-04-20 20:05 Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>
parent: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
0 siblings, 0 replies; 4+ messages in thread
From: Craig Orsinger @ 1999-04-20 20:05 UTC (permalink / raw)
To: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>; +Cc: pgsql-interfaces@postgreSQL.org, Matthew Hagerty <matthew@venux.net>
It also seems possible that you forgot to change the SQL
statement that you used to add the function(s) into the database.
Somewhere, you ran a SQL statement of the form:
create function bool2int(opaque) returns int4
as '/usr/local/pgsql/procs/bool2int.o'
language 'c';
So make sure you change that ".o" to ".so". BTW, this is
true on most Unix flavors, if not all. If you have to pass parameters
to the 'bool2int()' function, then describe them rather than using
the "opaque" description.
regards,
----------------------------------
Date: 20-Apr-99 Time: 13:00:02
Craig Orsinger (email: <orsingerc@epg.lewis.army.mil>)
Logicon RDA
Bldg. 8B28 "Just another megalomaniac with ideas above his
6th & F Streets station. The Universe is full of them."
Ft. Lewis, WA 98433 - The Doctor
----------------------------------
On 20-Apr-99 Gene Selkov, Jr. wrote:
>> ERROR: Can't find function bool2int in file
>> /usr/local/pgsql/procs/bool2int.o
>>
>
> That's probably because you are still looking in the object file. If
> you did not tweak the filenames, the linker should create a shared
> object file with the .so suffix, and it's likely that it did. Use
> 'file' to find out, like this (real example):
>
> file /home/wit/pgsql/ExtendedTypes/seg/seg.o
> /home/wit/pgsql/ExtendedTypes/seg/seg.o: ELF 32-bit LSB relocatable, Intel
> 80386, version 1, not stripped
>
> file /home/wit/pgsql/ExtendedTypes/seg/seg.so
> /home/wit/pgsql/ExtendedTypes/seg/seg.so: ELF 32-bit LSB shared object, Intel
> 80386, version 1, not stripped
>
>> I have tried every linker flag possible, nothing helps. Seems funny that a
>> function cannot be located in a library file?!?!
>
> Object files and shared libraries have different symbol tables, let
> alone the code.
>
> I remember building things painlessly in FreeBSD, but that was a
> couple years back, so I am not sure now. In any event, I would start
> with tutorial examples because these are almost guaranteed to
> work. Also, here's a complete code for a user-defined function -- you
> will only need to adjust the paths in the Makefile and in the sql
> script:
>
> http://wit.mcs.anl.gov/~selkovjr/foldit.tgz
>
> --Gene
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-04-20 20:05 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-20 06:41 Compiling a function Matthew Hagerty <matthew@venux.net>
1999-04-20 08:19 Re: [INTERFACES] Compiling a function Matthew Hagerty <matthew@venux.net>
1999-04-20 12:58 ` Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
1999-04-20 20:05 ` Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox