[fpc-pascal] fpc in symlinked directory

Michael Van Canneyt michael at freepascal.org
Wed Mar 26 09:10:09 CET 2014



On Tue, 25 Mar 2014, Mattias Gaertner wrote:

>>
>> So, FPC uses a system call to get the correct (resolved) CWD directory.
>> This is the only guaranteed mechanism.
>
> What's wrong with this:
>  if GetEnvironmentVariable('PWD')<>'' then
>    SetCurrentDir(GetEnvironmentVariable('PWD'));

It's a hack ?

> ?
>
>> So, the best Lazarus can do is resolve all directories before calling the compiler.
>
> If you mean with "resolve" to convert relative paths to absolute paths:
> That is not sufficient.

Yes it is. 
But you must do it correctly for ALL paths, and take care to use absolute paths only.
Relative paths and symlinks do not work.

> For example when the program uses a unit in the same directory, the
> compiler uses its current directory.

What does that mean ? Can you give a command-line example ? 
(sources and all)


>> Since you brought it up:
>> IMHO Lazarus must do this resolving anyhow, because now Lazarus does not work at all with symlinks, e.g. to find filenames and resolve packages. Regardless of what the compiler does.
>>
>> I submitted bugreports on the list about this in the past.
>
> I remember some problems. Formerly the IDE resolved symlinks, which
> was wrong. This was fixed.

That depends on what you call 'fixed' :)

I use a lot of symlinks. To this day, the IDE cannot handle them correctly.

I must always take great care not to select a project/package using a symlink,
but always must use the 'correct' resolved path.

The problem is the use of relative paths to indicate units of dependent packages. 
I have asked in the past to specify paths to packages as absolute 
paths, never relative: 
if you use relative paths, things will get messed up when using symlinks.

And it has nothing to do with the compiler, the compiler isn't called
when loading a package or a project, or specifying paths to packages.

Michael.



More information about the fpc-pascal mailing list