Firebird News

Tuesday, July 15, 2008

To use UDF modules in ubuntu/linux

You must put full path to the UDF module when you declare the function
in my case

otherwise you will get something like
"Invalid token. invalid request BLR at offset 63. function SUBSTR is not defined. module name or entrypoint could not be found."

--FBUDF_API int isLeapYear(const ISC_TIMESTAMP* v);
declare external function isLeapYear
returns int by value
entry_point 'isLeapYear' module_name '/usr/lib/firebird/2.1/UDF/';
then it worked

select isLeapYear(hire_date) from EMPLOYEE


radu said...


have you tried to write an entire UDF under ubuntu with lazarus, and to register it? i'm struggling with this issue, and until now i have no results.for example

in project file exports Modulo;

pas file:

function Modulo(var i, j: Integer): Integer; cdecl; export;

function Mo(var i, j: Integer): Integer; cdecl; export;
if (j = 0) then
result := -1
result := i mod j;

ok, after this build shared object with ppc386 or fpc. if everything goes ok, then you have the '.so'. Now registering part is a little tricky because due to firebird.conf sometimes UdfAccess must be setted up to Restrict UDF. i'm struggling with this issue, and because the debugging is so hard, i can not figure out where is the real issue.

any idea is welcomed,

best regards,

mariuz said...

I will check to see how can be tested on my ubuntu box (free pascal udf and firebird 2.1)

on my system i have UdfAccess = Full

mariuz said...

my fpc compiler is crazzy , i have tried to compile it but it gives me error

test.dpr(9) Error: Can't call the linker, switching to external linking
test.dpr(9) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)

mariuz said...

i have tried to help you also solve this issue

mariuz said...

How did you compiled from cmd line ?

zedalaye said...

I ran into the same issue today with Ubuntu Server 10.04 and Firebird Classic 2.1.3.

I solved the issue by adding /usr/lib/firebird/2.1/lib and /usr/lib/firebird/2.1/UDF to the ld.conf cache.

Just create a file like /etc/ with a directory per line.

Then run # ldconfig

Now, the system will find libraries stored in these paths and you won't have to define your external functions using the full path.

Don't know if there is a better way to achieve that.

Rajiv said...

Thanks. I was facing the same problem on Ubuntu 10.4.

Changing directory within UDF declaration was difficult due to dependencies.