Subject: Undefined symbol in user function

From: Vincent Schenkelaars <[email-masked]>
Date: Fri, 2 Sep 94 13:02:38 +0200

Dear Postgres Group,

I'm using postgres 4.2 on sunos4.3.1. I'm getting a undefined symbol _sin error
when using a simple test function with postgres.

I created the database test.
my c-function is:

#include "tmp/postgres.h"
#include <math.h>

float4 *
test(f)
  float4 *f;
{
  float4 *result;

  result = (float4 *) palloc(sizeof(float4));

  *result = sin(*f);
  return (result);
}

I compiled it with
cc -I$POSTGRESHOME/include -c test.c 
ld -dc -dp -Bdynamic -o test.so test.o

and I defined the function with:
define function test (language="c", returntype = float4) as
 "/export/local/geo-geo-ext/test.so"

when I do a retrieve (t = test(1::float4)) directly in the backend I get
ld.so: Undefined symbol: _sin.

What went wrong?  Shouldn't the backend have linked the libm.a file? 
Surely it didn't do it right.  When I remove the sin function in my c-source.
everything goes fine.

Please give me some clues?

Regards,
     ____________________   Vincent F. Schenkelaars
 \  / . _   _  _   _  |	    E-mail: [email-masked]
  \/ ( ( \ (_ (-' ( \ |     
			    "We apologize for the inconvenience"

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================

---

From: Tim Wadsworth <[email-masked]>
Date: Fri, 2 Sep 1994 14:43:23 +0100 (BST)

Vincent Schenkelaars writes:

> I'm getting a undefined symbol _sin error

I think you need to put a '-lm' option in your link directive, to
link with the math library.

Tim.

 ________________________________________________
|                                                |
| From Tim Wadsworth: [email-masked] |
|________________________________________________|