In message 64B83BAE.20010309232630.FOO-38E5.frank@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 wrote:
--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?
Basically yes. Without `--automake', GPC tries to behave as "dumb" as a C compiler, i.e. require all files to be linked to be mentioned on the command line. `gpc useunit.p helpunit.o' should work then. Though I don't actually see the point in not using `--automake'...
(I could set --unit-path to include the current directory, but you seem to be saying that should not be necessary.)
Nope. The unit path is for automake only, I think.
Frank