In message <64B83BAE.20010309232630.FOO-38E5.frank(a)g-n-u.de>
Frank Heckenbach writes:
> David James wrote:
>
> > Suppose I have a program that 'uses gpc' (one of the units from the
> > GPC RTS). Where should gpc.o and gpc*.gpi be (this is under Linux)?
> > And should they have been placed there by the make install when I
> > built the compiler?
> >
> > I'd like to be able to say gpc prog.p and have it automatically find
> > the gpc unit at compile time and at link time. At the moment I've
> > put gpc.o and gpc*.gpi in the same directory as the program, and am
> > specifying gpc.o in the command line, but there must be a neater way
> > of doing it ...
>
> The source of the units should remain in the directory where they're
> installed, i.e. <prefix>/lib/gcc-lib/<target>/<gcc-version>/units.
That's /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95.2/units in my
case.
> If GPC was built correctly, it should find them there automatically
> (try `gpc --print-file-name=units' if not).
which shows the directory above.
[snip]
> --automake
> compile units when necessary and link their object files
> automatically, so you won't have to specify gpc.o on the command
> line
Removing gpc.pas, gpc*.o, and gpc*.gpi from my own source directory
and using --automake allows the compile and link to succeed.
>
> --unit-path=DIR:DIR:...
> search path for other units, i.e. not those shipped with GPC (they
> should be found automatically) and not in the current directory --
I still have a problem here ... for me GPC (20010306) is not finding
units in the current directory at link-time.
For example:
helunit.p
=========
unit helunit;
interface
procedure writeit;
implementation
procedure writeit;
begin
writeln('Hello from unit');
end;
end.
========
useunit.p
=========
program useunit(output);
uses helunit;
begin
writeln('Hello world, and now ... from the unit');
writeit;
writeln(' ... and back in main');
end.
========
If I say
gpc -c helunit.p
and then
gpc useunit.p
I get:
/tmp/cc2caGt51.o: In function `pascal_main_program':
/tmp/cc2caGt51.o(.text+0x32): undefined reference to `Writeit'
/tmp/cc2caGt51.o: In function `init_pascal_main_program':
/tmp/cc2caGt51.o(.text+0x7f): undefined reference to `init_Helunit'
collect2: ld returned 1 exit status
>From what you say above, I would have expected this to work, and it
*did* work with GPC 19991030.
Is this the expected behaviour? (I could set --unit-path to include
the current directory, but you seem to be saying that should not be
necessary.)
--
David James
mailto:david@tcs01.demon.co.uk
Special Stage Rally results archive <URL:http://www.tcs01.demon.co.uk/>