Recent

Author Topic: [SOLVED] Problem with fpc.cfg  (Read 4690 times)

JoeJoeTV

  • Jr. Member
  • **
  • Posts: 65
  • Hobbyist Programmer
    • Useless Website
[SOLVED] Problem with fpc.cfg
« on: March 10, 2019, 05:54:09 pm »
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  [Select][+][-]
  1. @echo off
  2. echo Starting Lazarus...
  3. 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  [Select][+][-]
  1. 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?
« Last Edit: March 13, 2019, 03:35:34 pm by JoeJoeTV »
Lazarus 2.2.4 / FPC 3.2.2 / 64bit / Linux Mint 21.1 Cinnamon
https://github.com/JoeJoeTV

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Problem with fpc.cfg
« Reply #1 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.

JoeJoeTV

  • Jr. Member
  • **
  • Posts: 65
  • Hobbyist Programmer
    • Useless Website
Re: Problem with fpc.cfg
« Reply #2 on: March 12, 2019, 08:00:14 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.

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?
« Last Edit: March 12, 2019, 08:08:48 pm by JoeJoeTV »
Lazarus 2.2.4 / FPC 3.2.2 / 64bit / Linux Mint 21.1 Cinnamon
https://github.com/JoeJoeTV

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Problem with fpc.cfg
« Reply #3 on: March 12, 2019, 10:00:31 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?

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$
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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

JoeJoeTV

  • Jr. Member
  • **
  • Posts: 65
  • Hobbyist Programmer
    • Useless Website
Re: Problem with fpc.cfg
« Reply #4 on: March 13, 2019, 03:34:58 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?

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$
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.

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  [Select][+][-]
  1. @echo off
  2. echo Starting Lazarus...
  3. set "LAZDIR=%~dp0"
  4. 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?
« Last Edit: March 13, 2019, 06:50:35 pm by JoeJoeTV »
Lazarus 2.2.4 / FPC 3.2.2 / 64bit / Linux Mint 21.1 Cinnamon
https://github.com/JoeJoeTV

 

TinyPortal © 2005-2018