Forum > General

Cross Platform Procedure to Find Lazarus and FPC Executables

(1/3) > >>

simsee:
My application needs to run Lazarus and / or FPC. Therefore I would need to develop a cross platform procedure that automatically finds the absolute path of the Lazarus and FPC executables. I thought about using the information in environmentoptions.xml, but this file does not contain all the necessary information. Furthermore, it is not even trivial to write a procedure that finds a file with a certain name that works well on all file systems due to the their different organization (for example in FAT and NTFS, all drives must be enumerated, because they do not have a root directory). Do you have any suggestions? Thank you.

marcov:
There is no procedure because there is not guaranteed just one. FPC/Lazarus both allow multiple installations.

In nearly all cases, the "fpc" binary in the system PATH is the preferred one, and in more complicated it is best for the user to provide hints in your configuration. There is no centralized administration of installs in FPC files (though maybe you can query the system's  package system).

Then initialize that configuration by first checking if there is one in the PATH, and then maybe check some common paths. Maybe the Windows innosetup installer sets some registry key that you could query.

Martin_fr:
For Lazarus:

On Windows, the installer (if it is used) writes an entry to the list of "installed apps". So the uninstaller can be run from the OS. (see the inno setup files tools/install/windows/ in the lazarus dir)

For a 2ndary install there are some changes to the name of the entry (IIRC).

But people also can install Lazarus in many other ways. And they have nothing in common as to where the install will be going to. Or where to find any hints.

Mind that the lazarus config files, can also be anywhere. (on any OS).
Lazarus checks a lazarus.cfg in the same dir as the [start]lazarus.exe.




simsee:
Thanks Marcov. I hadn't thought about using the PATH environment variable. But I noticed that on my pc (with Windows 10), PATH does not have Lazarus / FPC paths among its paths.

marcov:

--- Quote from: simsee on August 01, 2022, 04:05:58 pm ---Thanks Marcov. I hadn't thought about using the PATH environment variable. But I noticed that on my pc (with Windows 10), PATH does not have Lazarus / FPC paths among its paths.

--- End quote ---

Yes, but such standalone installations are a sign that there might be multiple versions, so in that case it is probably better to prompt the user.

Navigation

[0] Message Index

[#] Next page

Go to full version