Frank Heckenbach wrote:
As other have pointed out, you also have to link the RTS (either explicitly `-lgpc -lm' or by using gpc for linking). ... The example C code does un-/initialize the RTS explicitly (_p_initialize/_p_finalize), as well as the Pascal unit and program init_pascal_main_program ().
If you have just units, you have to call init_Foo () (where Foo is the name of the unit) for each unit, except those which are used by other units (since their intializer is called by the other unit one's), but it doesn't hurt to call an initializer multiple times.
I did so now (see the sources attached), but it didn't really help. Compiling it with
gpc --automake -c foo.pas gcc -lgpc -lm footest.c foo.o -o footest
now yields the error message:
/tmp/ccPmuIkN.o: In function `main': /tmp/ccPmuIkN.o(.text+0x1b): undefined reference to `_p_initialize' /tmp/ccPmuIkN.o(.text+0x28): undefined reference to `_p_finalize' foo.o: In function `Bar': foo.o(.text+0x1c): undefined reference to `_p_stdout' foo.o(.text+0x21): undefined reference to `_p_write' foo.o(.text+0x2a): undefined reference to `_p_InOutRes' foo.o(.text+0x32): undefined reference to `_p_check_inoutres' foo.o: In function `init_Foo': foo.o(.text+0x5b): undefined reference to `_p_atexit' collect2: ld returned 1 exit status
What should I change?