[fpc-pascal] UDF+FREEBSD+FIREBIRD

KES kes-kes at yandex.ru
Wed Nov 12 03:43:38 CET 2008


library tkes2;

{$mode objfpc}
{$PACKRECORDS C}


function somefn: integer; cdecl; export;
begin
 somefn:= 3;
end;

exports
 //I do not do as:
 // somefn name 'somefn'; // because of this cause error tkes2(17,1) Error: Asm: Duplicate label somefn

 //so I do as:
 somefn name '_somefn';

end.

#fpc tkes2 -Xp
Free Pascal Compiler version 2.2.0 [2008/11/09] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: FreeBSD/ELF for i386
Compiling tkes2
Linking libtkes2.so
17 lines compiled, 0.1 sec

#ld -shared -soname libtkes2.so.1 -o libtkes2.so.1.0 -lc tkes2.o
#cp tkes2.so /usr/local/libexec/firebird/udf/
#cp tkes2.so.1.0 /usr/local/libexec/firebird/udf/
#cd /usr/local/libexec/firebird/udf/
#ls -l
-rwxr-xr-x  1 root  wheel      6022 12 ноя 04:07 libtkes2.so
-rwxr-xr-x  1 root  wheel      3219 12 ноя 04:32 libtkes2.so.1.0

# /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

in SQL:
DECLARE EXTERNAL FUNCTION FNTEST2
  RETURNS INTEGER BY VALUE 
  ENTRY_POINT 'tkes2__somefn'
  MODULE_NAME 'libtkes2'

select fntest2() from sometable;

invalid requiest BLR at offset 64
function FNTEST2 is not defined
module name or entrypoint could not be found

repeat:
DECLARE EXTERNAL FUNCTION FNTEST2
  RETURNS INTEGER BY VALUE 
  ENTRY_POINT 'tkes2_somefn'
  MODULE_NAME 'libtkes2'

select fntest2() from sometable;

invalid requiest BLR at offset 64
function FNTEST2 is not defined
module name or entrypoint could not be found

another try:

DECLARE EXTERNAL FUNCTION FNTEST2
  RETURNS INTEGER BY VALUE 
  ENTRY_POINT '_somefn'
  MODULE_NAME 'libtkes2'

select fntest2() from sometable;

invalid requiest BLR at offset 64
function FNTEST2 is not defined
module name or entrypoint could not be found


DECLARE EXTERNAL FUNCTION FNTEST2
  RETURNS INTEGER BY VALUE 
  ENTRY_POINT 'somefn'
  MODULE_NAME 'libtkes2'

select fntest2() from sometable;

invalid requiest BLR at offset 64
function FNTEST2 is not defined
module name or entrypoint could not be found



What is wrong?




More information about the fpc-pascal mailing list