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

KES kes-kes at yandex.ru
Sun Nov 16 21:31:35 CET 2008


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

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

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

K> Вы писали 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.

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

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

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

K> Any suggestions?

some additional tests:

home# fpc -Cn testudf.pp
Target OS: FreeBSD/ELF for i386
Compiling testudf.pp
Closing script ppas.sh
11 lines compiled, 0.1 sec
home# gcc testudf.o -o libtestudf.so -shared
home# cp libtestudf.so /usr/lib
home# gcc so_load.c
home# ./a.out
loading library failed /usr/lib/libtestudf.so: Undefined symbol "FPC_INITIALIZEUNITS"

In first case it does not found "main" in seconde FPC_INITIALIZEUNITS

Maybe I need some options?

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




More information about the fpc-pascal mailing list