The simple example we sent to gpc group isn't our real context, we cannot compile all the used units with automake option in compiling the program file. This is because some units are linked with the program module automatically, using a librarian ".a" file which contains handred and handred of unit, some of them use the gpc Trap unit.
So, for example, compiling a program file and then linking it with big librarian ".a" file, the undefined reference remains, also linking the gpclib.a and gcclib.a library files, eg.
gpc --automake -c ui.pas -o ui.o #automake to generate trap.gpi and gpc-all.gpi that don't exist in the gpc intallation #missing automake option gpc detect module/unit interface 'Trap' could not be imported gpc -c u1.pas -o u1.o gpc -c u2.pas -o u2.o .. gpc -c un.pas -o un.o ar rc ulib.a u1.o u2.o ... un.o ranlib ulib.a
gpc -c pi.pas -o pi.o
ld pi.o ulib.a gpclib.a gcclib.a -o p.exe
or, also
gpc pi.o ulib.a gpclib.a gcclib.a -o p.exe
to solve the undefined reference have I also to link the trap.o and trapc.o files???
Angelo
To: Angelo.Fumagalli@alcatel.it; gpc@gnu.de Sent: Thursday, April 07, 2005 5:06 PM Subject: Re: Link/Load problem using gpc Trap unit
Angelo.Fumagalli@alcatel.it wrote:
we are using gpc-20041218 with gcc-2.95.2 on Sparc Solaris 2.8 and we
found
a gpc link problem when linking user object file compiled separately and then linked in a final step.
For example, a simple case: if we have two gpc source files (a program pi.pas which calls a procedure defined in a separeted unit ui.pas which
uses
the gpc Trap unit) compiled in different steps and then linked together
in a
final step, the references related to the gpc unit remain undefined when linking/loading the object files, for example:
gpc --automake -c ui.pas -o ui.o gpc --automake -c pi.pas -o pi.o gpc --automake pi.o ui.o -o p.exe
You're mixing two partly incompatible methods, automake and explicit linking.
Remove all *.o and *.gpi files (to be sure), then do just `gpc --automake -o p.exe pi.pas' (assuming that's your main program).
(The issue is that the Trap unit uses another file, trapc.c. Automake deals with it transparently due to a `{$L}' directive, but only if you let it.)
You might also want to try gp (http://fjf.gnu.de/misc/gp.tar.bz2) which is planned to replace automake in the future. After installing it, call it like gpc (you can omit the `--automake' option then which gp just ignores).
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0
E5E8