Subject Re: [firebird-support] UDF + FreePascal + Firebird 1.5
Author Jacqui Caren
Guto wrote:
> I created a UDF, just to test and try to discovery what's wrong.
> I ill explain what I did step by step.
> I created a teste.pas file like this:
> ----
> library teste;
> function intmax(a,b: Integer): Integer; stdcall; export;
> begin
> if a>b then intmax:=a else intmax:=b;
> end;
> exports
> intmax;
> end.
> ----
> I compile with freepascal:
> fpc teste
> I moved to udf directory on firebird:
> mv /usr/local/firebird/UDF/
> I changed permissions:
> cd /usr/local/firebird/UDF
> chown firebird:firebird
> chmod 550
> I declared UDF:

Did you enable UDF's by
* setting the 'RootDirectory = /opt/firebird
* uncommenting the 'UdfAccess = Restrict UDF' line

My UDFs would not work until I had did both modifications
(applied in the order shown). You should not require the
latter but it does not hurt to explicitly configure things.

Hint: try
RETURNS parameter 2 BY VALUE
if you get junk values returned.
> ENTRY_POINT 'intmax' MODULE_NAME 'teste';

To ensure that the error message is incorrect.

If this is on linux try
nm -g | grep -i intmax
which should show you the name of the entry point
(on the line of the form ' T intmax')
within the .so (hint: some compilers can append a prefix).

If no such line exists then your function is not in the .so.
If the name has a prefix such as p_intmax then try changing
the entry point to this and see what happens.