Cross Platform Procedure to Find Lazarus and FPC Executables lazarus / 62-General ---------------------------------------------------------------------- simsee · 2022-08-01 13:44 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 · 2022-08-01 13:59 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 · 2022-08-01 14:05 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 · 2022-08-01 14:05 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 · 2022-08-08 14:24 Quote from: simsee on August 01, 2022, 04:05:58 pmThanks 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. 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. ---------------------------------------------------------------------- MarkMLl · 2022-08-08 16:03 Quote from: marcov on August 08, 2022, 04:24:29 pmYes, 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. Although certainly in the Linux case, a single (and usually recent) fpc binary can invoke multiple compiler backends (-V option etc.). The result of that is that once there's a single fpc binary on the path and multiple (appropriately-named) ppcXXX binaries, the internal paths set up during installation take over. I mention this not to find fault with what anybody's written, but in case it's possible to make use of it during installation to simplify things. MarkMLl ---------------------------------------------------------------------- marcov · 2022-08-08 18:19 Quote from: MarkMLl on August 08, 2022, 06:03:36 pmQuote from: marcov on August 08, 2022, 04:24:29 pmYes, 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. Although certainly in the Linux case, a single (and usually recent) fpc binary can invoke multiple compiler backends (-V option etc.). I know, I added it in 9b39a588c3c54a831b7e4b0837a7296e623617c6 But it still doesn't help you enumerate the variants. ---------------------------------------------------------------------- MarkMLl · 2022-08-08 18:22 Quote from: marcov on August 08, 2022, 08:19:14 pmI know, I added it in 9b39a588c3c54a831b7e4b0837a7296e623617c6 Really? I thought it predated the use of Git. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2022-08-08 20:46 Quote from: simsee on August 01, 2022, 03:44:39 pmMy 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. At least for Windows I posted an utility here that lists all the FPC and Lazarus installations. You could use that code plus looking through the directories of the PATH variable (which is more cross platform) to generate a list. Quote from: MarkMLl on August 08, 2022, 08:22:31 pmQuote from: marcov on August 08, 2022, 08:19:14 pmI know, I added it in 9b39a588c3c54a831b7e4b0837a7296e623617c6 Really? I thought it predated the use of Git. The whole repository including all SVN and even CVS commits was converted to Git. It simply makes no sense anymore to refer to SVN commits, because they wouldn't be accessible anyway. So the correct way is to post the Git hash of the commit which will not change anyway. Though it would have been nice of marcov to post a link to the commit as well... ---------------------------------------------------------------------- MarkMLl · 2022-08-08 20:53 Quote from: PascalDragon on August 08, 2022, 10:46:26 pmThe whole repository including all SVN and even CVS commits was converted to Git. It simply makes no sense anymore to refer to SVN commits, because they wouldn't be accessible anyway. So the correct way is to post the Git hash of the commit which will not change anyway. Though it would have been nice of marcov to post a link to the commit as well... Just this once, I'll admit I was trolling. But you know my feeling about the loss of linear revision numbers, and I feel that giving one for a patch during which they were still "what mattered" would have been appropriate. MarkMLl ---------------------------------------------------------------------- marcov · 2022-08-08 20:53 Quote from: PascalDragon on August 08, 2022, 10:46:26 pmThe whole repository including all SVN and even CVS commits was converted to Git. It simply makes no sense anymore to refer to SVN commits, because they wouldn't be accessible anyway. So the correct way is to post the Git hash of the commit which will not change anyway. Though it would have been nice of marcov to post a link to the commit as well... There is a conversion/mapping file for SVN that is useful for revisions in commit messages. The mergelogs use it, and it will be needed at least till the current release cycle is complete.