[fpc-devel] Problems linking FPC-built library into C program on linux x86_64

Dominique Leducq dleducq at magellan-ing.fr
Wed May 24 15:03:50 CEST 2006


Hi again,

I still don't succeed in linking Free Pascal compiled code with a C program.

When linking with the shared library built by fpc, I have problems with undefined symbols, which are defined in the loaders. 

$ gcc -o test_shared test2.o -L. -lsoTest3
./libsoTest3.so: undefined reference to `__stkptr'
./libsoTest3.so: undefined reference to `_haltproc'
./libsoTest3.so: undefined reference to `operatingsystem_parameter_argc'
./libsoTest3.so: undefined reference to `operatingsystem_parameter_argv'
collect2: ld returned 1 exit status

When linking in the loader prt0.o too, there are symbol conflicts with /usr/lib/crt1.o (_start, __data_start) if I call ld through gcc.

$ gcc -o test_shared test2.o prt0.o -L. -lsoTest3
prt0.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../lib64/crt1.o:../sysdeps/x86_64/elf/start.S:65: first defined here
prt0.o: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../lib64/crt1.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status


Exactly the same happens when linking statically.


 If I call ld directly, linking succeeds, but the main() of the C program never gets called...

However, according to the FPC Programmer's Guide, "using a pascal library from a C program" (12.4) seems to be supported...

Do I miss something ?

Thx for your help,

Dominique Leducq




More information about the fpc-devel mailing list