Forum > Windows (32/64)

[SOLVED] Problem with fpc.cfg

(1/1)

JoeJoeTV:
Hi!

I have Lazarus 2.0.0 32bits and I want to install it on a usb drive, so I could use it on other PC's where I can't install any software.

So i used the normal Lazarus installer to install it on the drive and set the config path to a directory in the main lazarus directory.
Then I edited the Lazarus path variables to use the %(LazarusDir) variable and I created a little script to start lazarus and set the path:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---@echo offecho Starting Lazarus...cmd /C ""%~dp0startlazarus.exe" --lazarusdir="%~dp0" --pcp=%~dp0LazConfig --scp=%~dp0 --skip-last-project"
Lazarus Paths:
Lazarus directory: Set by the script
Compiler executable: $(LazarusDir)\fpc\3.0.4\bin\i386-win32\fpc.exe
FPC source directory: $(LazarusDir)\fpc\$(FPCVer)\source
"Make" executable: $Path($(CompPath))\make.exe
Directory for building test projects: $(LazarusDir)\Temp\ (I created the foldewr "Temp")

And this works fine until I try to compily anything. It just throws the error:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Fatal: Cannot find strutils used by LazUTF8 of package LazUtils.
After that I tried adding $(LazarusDir) to the paths in fpc.cfg, but that doesn't work.

I also tried searching the forums, but didn't find anything that worked.

Does anyone know how to solve this?

Leledumbo:
fpc.cfg is not managed by Lazarus, as in this portable installation the paths are also moved, you need to change fpc.cfg contents dynamically as well, primarily the -Fu lines. Note that Lazarus macros (like $(LazarusDir)) won't work there, you must supply actual path.

JoeJoeTV:

--- Quote from: Leledumbo on March 12, 2019, 02:49:56 pm ---fpc.cfg is not managed by Lazarus, as in this portable installation the paths are also moved, you need to change fpc.cfg contents dynamically as well, primarily the -Fu lines. Note that Lazarus macros (like $(LazarusDir)) won't work there, you must supply actual path.

--- End quote ---

Oh, thanks for explaining this, I will try doing this with a script or soimething.

EDIT:
I just looked at the fpc config file and noticed that the config used a variable: $fpctarget, and I thought, couldn't you somehow pass the $LazarusDir variable to fpc in lazarus or something?

lucamar:

--- Quote from: JoeJoeTV on March 12, 2019, 08:00:14 pm ---I just looked at the fpc config file and noticed that the config used a variable: $fpctarget, and I thought, couldn't you somehow pass the $LazarusDir variable to fpc in lazarus or something?

--- End quote ---

I think you need to read this in the User's Guide: Variable substitution in paths

Note specially this paragraph:
--- Quote from: Free Pascal User's Guide ---Normally, only a set of compiler-defined variable names are recognized. In addition to these compiler-defined variable names, the following notation can be used

$ENVVAR$
--- End quote ---
So to pass the lazarus dir to fpc.cfg you may set an environment var, with say:
  set LAZDIR="H:\Lazarus"
and, in your fpc.cfg, use $LAZDIR$ wherever you need it.

JoeJoeTV:

--- Quote from: lucamar on March 12, 2019, 10:00:31 pm ---
--- Quote from: JoeJoeTV on March 12, 2019, 08:00:14 pm ---I just looked at the fpc config file and noticed that the config used a variable: $fpctarget, and I thought, couldn't you somehow pass the $LazarusDir variable to fpc in lazarus or something?

--- End quote ---

I think you need to read this in the User's Guide: Variable substitution in paths

Note specially this paragraph:
--- Quote from: Free Pascal User's Guide ---Normally, only a set of compiler-defined variable names are recognized. In addition to these compiler-defined variable names, the following notation can be used

$ENVVAR$
--- End quote ---
So to pass the lazarus dir to fpc.cfg you may set an environment var, with say:
  set LAZDIR="H:\Lazarus"
and, in your fpc.cfg, use $LAZDIR$ wherever you need it.

--- End quote ---

Thanks, that worked perfectly. I now have a small batch file, that has to be executed to start lazarus portable(for anyone wanting to do the same):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---@echo offecho Starting Lazarus...set "LAZDIR=%~dp0"cmd /C ""%LAZDIR%startlazarus.exe" --lazarusdir="%LAZDIR%" --pcp=%LAZDIR%LazConfig --scp=%LAZDIR% --skip-last-project"
NOTE:
The batch file has to be located in the lazarus directory and there has to be a "LazConfig" directory in the Lazarus directory

EDIT:
It now works on multiple systems, but everytime the drive letter changes, lazarus warns on startup about different config, is there a command line option or something to just ignore it all the time?

Navigation

[0] Message Index

Go to full version