[fpc-pascal] UDF+FREEBSD+FIREBIRD FPC generate wrong object file???

KES kes-kes at yandex.ru
Sun Nov 16 21:25:39 CET 2008

Здравствуйте, Michael.

Вы писали 16 ноября 2008 г., 0:29:22:

MVC> On Sat, 15 Nov 2008, KES wrote:

>> Здравствуйте, Michael.
>> Вы писали 15 ноября 2008 г., 23:28:10:
>> MVC> On Sat, 15 Nov 2008, KES wrote:
>> >> Здравствуйте
>> >> 
>> >> h) select fntest() from rdb$database
>> >> i) invalid requiest BLR at offset 60
>> >> function FNTEST is not defined
>> >> module name or entrypoint could not be found
>> >> 
>> >> 
>> >> CONCLUSION: FPC generate wrong object file???
>> MVC> Not necessarily. Please try to load the library from a plain C program.
>> MVC> My guess is that dlopen() will return an error.
>> MVC> Then do the same for the library with a pascal program.
>> MVC> Michael.
>> I do not know how to load the library from a plain C program. Can you
>> help me?

MVC> Something like this should do it:

home: >>cat testl.c
MVC> #include <dlfcn.h>
MVC> #include <stdio.h>
MVC> int main () {
MVC>   void * p;
MVC>   void * ps;
MVC>   p=dlopen("testudf.so",RTLD_NOW);
MVC>   if (p==NULL) {
MVC>     printf("loading library failed %s\n",dlerror());
MVC>   } else {
MVC>     printf("loading library OK\n");
MVC>     ps = dlsym(p,"fn_test");
MVC>     if (ps==NULL) {
MVC>       printf("symbol not found\n");
MVC>     } else {
MVC>       printf("Symbol found OK\n");
MVC>     }
MVC>    dlclose(p);
MVC>   }
MVC> }

home: >>gcc -ldl testl.c
home: >>./a.out
MVC> loading library failed testudf.so: cannot open shared object file: No such file or directory

MVC> Of course,  you must correct the names.

MVC> Michael.

home# ./a.out
loading library failed /usr/lib/libtestudf.so: Undefined symbol "main"

in output of nm libtetudf.so
I have noticed this:
0001d950 t gcc2_compiled.
         U main
00039758 B operatingsystem_parameter_argc
"U main" what this mean??

Now I try your example for .so compiled by gcc
home# gcc -c testudf.c
home# gcc testudf.o -o testudf.so -shared
home# gcc so_load.c
The so_load.c file is test1.c
home# ./a.out
loading library failed Shared object "testudf.so" not found, required by "a.out"
home# cp testudf.so /usr/lib
home# ./a.out
loading library OK
Symbol found OK

Any suggestions?

С уважением,
 KES                          mailto:kes-kes at yandex.ru

More information about the fpc-pascal mailing list