Recent

Author Topic: Lazarus portable?  (Read 1182 times)

sl23

  • Newbie
  • Posts: 6
Lazarus portable?
« on: November 04, 2025, 06:40:09 pm »
Here is what I have done:
I tried extracting Lazarus installer for portable use, it worked, but doesn't create the fpc.cfg file. I didn't know how to get around that, so I then installed it via Sandboxie-plus. This basically done the same thing, but I don't know what registry settings were created. I then downloaded the WinPenPack X-Lazarus, which is way out of date now, then moved the Sandboxed install to the new location. I am having several issues, which I have found are due to the fpc.cfg settings not being correct.

I searched here for topics on this and nothing I found is answering my questions. Sorry if this has been gone through before, but I am new to Lazarus and programming. I have no idea how to use the app but want to learn.

So using AI, I have spent nearly five hours troubleshooting why I cannot compile and the upshot is that relative paths are meant to be supported but are not working in the fpc.cfg file, according to GitHub Copilot! Yeah, I know, but I have no other way to sort it out, not quickly, forums tend to be slow in response times, and I just wanted to get on and get it sorted.

Anyway, from what I see, some variables are used to create relative paths like the $FPCVERSION one for example. Are there any other variables I can use for relative paths?

I was given this as a relative path by Copilot, but it doesn't seem to work:
-Fu..\..\source\packages\rtl-objpas\src\inc

Do those types of relative paths work in the fpc.cfg file? I just want the drive letter removed as the location will be static on a USB device. But if there is a way to completely make the app and locations fully portable, I would like to know more.

I guess the question I wanted to ask has already been answered and is a resounding no? See ing as it hasn't happened in  the last 15 years or so. I see posts about making Lazarus portable, but seems little has been done about making it natively portable. Is that a possibility? Would the dev's ever consider making the app fully portable?

Thanks and apologies for repeating what has likely been covered in previous posts! I did try the search but found little of help.

Handoko

  • Hero Member
  • *****
  • Posts: 5485
  • My goal: build my own game engine using Lazarus
Re: Lazarus portable?
« Reply #1 on: November 04, 2025, 06:44:42 pm »
Hello sl23,
Welcome to the forum.

I haven't tried but I remember there were several success attempts to create portable version of Lazarus. Try search the forum, you should find the information you need.

wp

  • Hero Member
  • *****
  • Posts: 13195
Re: Lazarus portable?
« Reply #2 on: November 04, 2025, 06:56:54 pm »
I have this one in my bookmarks, but never tried it myself: https://github.com/JoeJoeTV/startLazarusPortable

As for fpc.cfg, did you try the fpcmkcfg utility? Maybe this batch file helps (you are on Windows, aren't you?).
Code: [Select]
set FPC_DEST_DIR=j:\Lazarus\fpc-main-32bit
set BIN_DIR=bin\i386-win32
set FPC_BIN_DIR=%FPC_DEST_DIR%\%BIN_DIR%
fpcmkcfg -d basepath=%FPC_DEST_DIR% -o %FPC_BIN_DIR%\fpc.cfg
But besides that, I think paths must be adjusted also in the Lazarus configuration files?

Cascade

  • Jr. Member
  • **
  • Posts: 57
Re: Lazarus portable?
« Reply #3 on: November 04, 2025, 08:22:27 pm »
I've considered writing a StartLazarus type of app that would first check to see whether Lazarus has moved before launching the main IDE.  If so it would run a big recursive search and replace to update all the paths.  But that would be a bit of a blunt brute force approach, and makes the assumption of a self-contained FpcUpDeluxe kind of install to start with.

I think it might be really neat if at some future point FPC and Lazarus referenced a single Base path each in their config files - and used that throughout.  That way only a couple of paths entries would need updating whenever the app is moved.  That could make portability viable.  Not sure I've explained that well.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Lazarus portable?
« Reply #4 on: November 04, 2025, 08:49:16 pm »
I've considered writing a StartLazarus type of app that would first check to see whether Lazarus has moved before launching the main IDE.

I once did something like that: http://www.stack.nl/~marcov/Lazarus.bat

Quote
@echo off
rem
rem Simple script to relocate lazarus to use the current driveletter as
rem path, and put basic portable app support in lazarus.
rem
rem Assumes lazarus is in drvletter:\lazarus and config in
rem $lazarusdir/config
rem
rem For this to work, everything should be relative wrt $(lazarusdir)
rem inside the IDE. If packages work is currently untested

Set DRV_LETTER=%cd:~0,1%:
set LAZARUSDIR=%DRV_LETTER%\lazarus
set FPCROOTDIR=%LAZARUSDIR%\fpc\2.6.0
set FPCBINDIR=%FPCROOTDIR%\bin\i386-win32
set LAZARUSCONFIG=%LAZARUSDIR%\config

for %%i in (%LAZARUSDIR%\fpc\*) do set ALTFPCROOTDIR=%%i

echo %ALTFPCROOTDIR%

%DRV_LETTER%
cd \

REM The next on one line

%FPCBINDIR%\fpcmkcfg -d basepath=%FPCROOTDIR% > %FPCBINDIR%\fpc.cfg

cd %LAZARUSDIR%

rem startlazarus? untested as yet
rem should later get --lazarusdir=%LAZARUSDIR% if mantis 15741 (0.9.30+) is committed
rem
Lazarus.exe --primary-config-path=%LAZARUSCONFIG% --lazarusdir=%LAZARUSDIR%

It does require a portable base install though, so that the XML files are populated with paths relative to $lazarusdir

Quote
I think it might be really neat if at some future point FPC and Lazarus referenced a single Base path each in their config files - and used that throughout.  That way only a couple of paths entries would need updating whenever the app is moved.  That could make portability viable.  Not sure I've explained that well.

fpc.cfg paths are afaik relative to the location of fpc.cfg.

sl23

  • Newbie
  • Posts: 6
Re: Lazarus portable?
« Reply #5 on: November 04, 2025, 10:36:24 pm »
Thank your for all your help and taking time to reply.
Sorry, yes I should have mentioned, I am on Win1125H2.

I am not too sure about those methods, I am mostly confident in the X-Launcher, despite it's age, I did manage to update the code to 64bit with the latest AutoIT version and it seems to be doing the job still, unless there's been any changes with registry locations? Probably likely over that long period.

But that last sentence was very useful:
Quote
fpc.cfg paths are afaik relative to the location of fpc.cfg.
That is helpful and if I could get some elaboration on that, that would be great! For instance, is using something like this allowed within that file:
Code: Pascal  [Select][+][-]
  1. -Fu..\..\source\packages\rtl-objpas\src\inc
If it is, I am unable to get it to work, so if anyone would be able to give some advice on how to use that, please do.
Much appreciated.
« Last Edit: November 04, 2025, 10:42:13 pm by sl23 »

wp

  • Hero Member
  • *****
  • Posts: 13195
Re: Lazarus portable?
« Reply #6 on: November 04, 2025, 11:05:18 pm »
fpc.cfg paths are afaik relative to the location of fpc.cfg.
Really? In all FPC installations that I have on my desk, fpc.cfg contains absolute paths.

sl23

  • Newbie
  • Posts: 6
Re: Lazarus portable?
« Reply #7 on: November 04, 2025, 11:24:25 pm »
Yes as does my install. But I am wondering if relative paths are supported as mentioned. Would you know if they are?

I have looked through the manuals, but can find no reference to the fpc.cfg file at all.

sl23

  • Newbie
  • Posts: 6
Re: Lazarus portable?
« Reply #8 on: November 05, 2025, 12:08:00 am »
Well, I reinstalled into a sandbox location that mimics the actual location and copied the files over to the original location, ie, outside the sandbox. It works fine. I also changed all paths inside the fpc.cfg to relative, ie: Replaced -FuD:\path\to\Lazarus\fpc with -Fu..\.. and that works so far. Maybe there are some other settings files needing path changes? I don't know, but I will look into that too.

dbannon

  • Hero Member
  • *****
  • Posts: 3556
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazarus portable?
« Reply #9 on: November 05, 2025, 12:22:23 am »
On my system, Linux, relative to the current working directory seems to work fine for just FPC compiling.

In a (temp) fpc.cfg file every relevant path to have a ../../.. in front. eg

Code: [Select]
# searchpath for units and other system dependent things
-Fu../../../bin/FPC/fpc-$fpcversion/units/$fpctarget
-Fu../../../bin/FPC/fpc-$fpcversion/units/$fpctarget/*
-Fu../../../bin/FPC/fpc-$fpcversion/units/$fpctarget/rtl

Important point is the path is relative to current directory, not the location of fpc.cfg . I moved my fpc.cfg file to a lower directory and it still worked :

Code: Bash  [Select][+][-]
  1. fpc -vt  -n @config/fpc.cfg test.pas

Unsure how this translates to Windows, not my game !

Davo


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

wp

  • Hero Member
  • *****
  • Posts: 13195
Re: Lazarus portable?
« Reply #10 on: November 05, 2025, 12:31:37 am »
In the Lazarus config folder, there are absolute paths in environmentoptions.xml ("LazarusDirectory", "CompilerFileName", "ExternalTools"), codeunitdictionary.txt, fpcdefines.xml, iconfinder.cfg (if installed), idemake.cfg, packagefiles.xml, pochecker.xml, etc (plus lots of history items)

dbannon

  • Hero Member
  • *****
  • Posts: 3556
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazarus portable?
« Reply #11 on: November 05, 2025, 12:55:15 am »
Indeed, in my lazarus config too, eg
Code: Bash  [Select][+][-]
  1. dbannon@dell:~/Pascal/CLI/Works$ grep home ~/bin/Lazarus/LazConfigs/lazarus-fixes-4/*.xml | grep home | wc -l
  2. 118
  3.  

And they mention absolute paths to FPC as well. fpc is easy,  Lazarus not looking so good.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

BrunoK

  • Hero Member
  • *****
  • Posts: 716
  • Retired programmer
Re: Lazarus portable?
« Reply #12 on: November 05, 2025, 11:36:18 am »
For lazarus, it is also possible to use macro's in various menu/option/environment fields.
 For example here are some values I have in my C:\fpc-laz\Lazarus\4.99_GIT_251021\Config_FpcTrunk\environmentoptions.xml

Code: Pascal  [Select][+][-]
  1. <CompilerFilename Value="$(FPCSRCDIR)\bin\$(TargetCPU)-$(TargetOS)\ppcx64.exe">
  2. <FPCSourceDirectory Value="$(ConfigDir)\..\..\..\fpc\3.2.2-git">
  3. <MakeFilename Value="$(FPCSRCDIR)\..\win_utils\i386-win32\make.exe">
  4.  


They are relative to the "root" $(ConfigDir) as defined in the shortcut.

d2010

  • Full Member
  • ***
  • Posts: 230
Re: Lazarus portable?
« Reply #13 on: November 05, 2025, 03:11:22 pm »
Indeed, in my lazarus config too, eg
Code: Bash  [Select][+][-]
  1. dbannon@dell:~/Pascal/CLI/Works$ grep home ~/bin/Lazarus/LazConfigs/lazarus-fixes-4/*.xml | grep home | wc -l
  2. 118
  3.  
Davo

First I have two operating  system. Win10 .. & U have installed Lazarus x86.
Today I  boot on "WinPeBoot of Win7", with x86,,  the drive C: inside Win10 is 100% equal with drive C: inside "WinPeBoot of Win7.iso"
I run  "Start Lazarus.exe" inside "WinPeBoot of Win7", and He=Lazarus work 100%
perfectly., No need re-config, scan path, no need search others / dll
Thank you(2025)Lazarus.
« Last Edit: November 05, 2025, 03:12:57 pm by d2010 »

sl23

  • Newbie
  • Posts: 6
Re: Lazarus portable?
« Reply #14 on: November 05, 2025, 03:33:15 pm »
I did manage to successfully replace all absolute paths in the fpc.cfg, but Lazarus doesn't accept these. Maybe there are macros as someone mentioned? I tried using this in the settings window, which failed:
$(LazarusDir)\fpc\$FPCVERSION\bin\x86_64-win64\fpc.exe
and then:
$(LazarusDir)\fpc\$(FPCVERSION)\bin\x86_64-win64\fpc.exe
But those $FPCVERSION macros aren't recognised.

Is there anything I can replace them with?

 

TinyPortal © 2005-2018