I tried to create a simple user defined function (UDF) for Firebird 2.5 with C++ Builder 2010 but I don't manage to get it to work in Firebird.
- Creating a DLL project with default setting in C++ Builder 2010.
Adding a unit with my example UDF including "ibase.h" and "ib_util.h":
extern "C" __declspec(dllexport) int __stdcall MYFUNC ( int i ) { int result = 2 * i; return result; }
Building the DLL
FBUDFMBD.dll
in pathC:\Program Files (x86)\Firebird\Firebird_2_5\UDF
Registering my UDF via IBExpert in a sample db with
DECLARE EXTERNAL FUNCTION F_MYFUNC INTEGER RETURNS INTEGER ENTRY_POINT 'MYFUNC' MODULE_NAME 'FBUDFMBD';
Calling the UDF with
select F_MYFUNC( 3 ) from RDB$DATABASE;
results in error message
Invalid token. invalid request BLR at offset 36. function F_MYFUNC is not defined. module name or entrypoint could not be found.
With the tool GExperts - PE Information I can see my UDF as DLL-Export MYFUNC
ordinal $1
and entry point $1538
.
What I am doing wrong, Firebird can't register my DLL and its UDF correctly?
Is there anything in my DLL project to change regarding to default compiler options?