未定义的符号:尝试调用UDF时的ib_util_malloc

时间:2016-06-25 09:08:54

标签: c firebird udf firebird-3.0

我创建了一个非常简单的UDF,编译得很好但是当我尝试使用它时,它会出现以下错误:

root@chii:/data/database/bot# /opt/firebird/bin/isql chii.fdb
Database: chii.fdb, User: SYSDBA
SQL> select YKUDF_PERLWRAPPER('/bin/ls' , '-al') from rdb$database;
/opt/firebird/bin/isql: symbol lookup error: /opt/firebird /UDF/YKUDFPerlWrapper: undefined symbol: ib_util_malloc

这是我的sql声明:

declare external function YKUDF_PERLWRAPPER
cstring(1024), cstring(1024)
returns cstring(16384) free_it
entry_point 'perlwrapper' module_name '/opt/firebird/UDF/YKUDFPerlWrapper';

my function.c:

#include <stdio.h>
#include <ctype.h>
#include "functions.h"
#include "ibase.h"
#include "ib_util.h"


extern void * ib_util_malloc(long);


char * perlwrapper (file, input)
     char * file;
     int * input;
{

  FILE *fp;
  char merged[1024];

  strcpy(merged, file);
  strcat(merged, " \"");
  strcat(merged, input);
  strcat(merged, "\"");

  fp = popen(merged, "r");    /* Issue the command.   */


  /* Read a line      */
  char line[1024];      /* line of data from unix command*/
  char output[16382];
  strcpy(output," ");

  while ( fgets( line, sizeof line, fp))
  {
    strcat(output,line);
  }
  pclose(fp);

  int i;
  int len = strlen(output);
  char * result = (char *) ib_util_malloc (len + 1);

  for (i = 0 ; i < len ; i++)
    result[i] = output[i];
  result[i] = (char) 0;

  return result;
}

my function.h:

#define PROTO_LIST(list) ()

char * perlwrapper PROTO_LIST ((char *, char *));

我的编译器:

gcc functions.c -DIB60 -fpic -O -c -w -shared -I/opt/firebird/include -L/opt/firebird/lib -lib_util -lstdc++ -lm -lc -o functions.o
ld functions.o -o YKUDFPerlWrapper -G -Bsymbolic -lgds -lm -lc 

试图在网上搜索ib_util_malloc,但大多数问题都没有得到答复。

0 个答案:

没有答案