Recent

Author Topic: Compiling Lazarus  (Read 1036 times)

440bx

  • Hero Member
  • *****
  • Posts: 4759
Compiling Lazarus
« on: September 03, 2024, 02:41:14 am »
Hello,

As some of you already know, Lazarus cannot and should _not_ be built using the .lpi file it comes with.

I was wondering about what exactly prevents compiling Lazarus using its .lpi file and could whatever the reason(s) is/are be reasonably and successfully circumvented ?

IOW, what makes Lazarus the one (or one of the very few) program(s) developed using Lazarus that cannot be built using its .lpi file ?

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

af0815

  • Hero Member
  • *****
  • Posts: 1380
Re: Compiling Lazarus
« Reply #1 on: September 03, 2024, 06:13:25 am »
who know (or say) this ?

It is not the prefered/usual way. Normal use the internal recompile or the make way - yes. But, if you want to debug Lazarus, you must compile Lazarus with the lpi.

And dont forget for lazbuild and startlazarus, this two programm are often forgotten to make all working like a charm. This can be a reason for people to say, dont use the lazarus.lpi alone.
regards
Andreas

440bx

  • Hero Member
  • *****
  • Posts: 4759
Re: Compiling Lazarus
« Reply #2 on: September 03, 2024, 06:58:29 am »
who know (or say) this ?

<snip>

But, if you want to debug Lazarus, you must compile Lazarus with the lpi.
No, I learned the hard way that doesn't work.  if you want to know all the details, you can find them in this thread: https://forum.lazarus.freepascal.org/index.php/topic,67710.msg521851.html#msg521851

Compiling using the .lpi resulted in a mess.

That said, if anyone can provide a way to successfully use the .lpi to produce a workable and debuggable version of Lazarus, I'd very much appreciate that.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8045
Re: Compiling Lazarus
« Reply #3 on: September 03, 2024, 08:56:34 am »
Compiling using the .lpi resulted in a mess.

"Up to a point, Lord Copper."

/First/, build using the makefile. Start the IDE to make sure that a configuration directory exists or is created. After that rebuild using lazbuild (i.e. the .lpi file etc.) since that is the only way to incorporate extra packages ** .

** Other than doing it from inside the IDE, but that results in a mess if you are trying to maintain parallel binaries for e.g. Qt and GTK.

I went through this exercise repeatedly a few months ago, when I wanted binaries (etc.) for Qt and GTK, and wanted LazMapViewer etc. installed in both. Ended up with quite a long (but maintainable) shell script.

MarkMLl
« Last Edit: September 03, 2024, 10:47:01 am by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

BrunoK

  • Hero Member
  • *****
  • Posts: 623
  • Retired programmer
Re: Compiling Lazarus
« Reply #4 on: September 03, 2024, 10:12:53 am »
Windows only.
=============

My folder structure :

Structure du dossier pour le volume HD
Le num‚ro de s‚rie du volume est 000000AA D264:A136
C:\FPC-LAZ
| etc...
|
|+---fpc
|   +---3.2.2-git
|   | etc...
|   \---win_utils
|       +---i386-win32
|       |   +---fpc-306
|       |   \---fpc264
|       \---x86_64-win64
| etc...
+---Lazarus
|   +---3.2
|   | etc...
|   +---3.99_GIT_240829   (0)
|   |   +---Config        (1)
|   |   |   etc...
|   |   +---Config_dbg    (2)
|   |   |   etc...
|   |   +---ide           (3)
|   |   |   etc...
| etc...



See how paths look compared to you own install and adjust.

(0) Where I cloned the last lazarus GIT version
(1) The configuration directory for normal installation
(2) The configuration directory for the debug version
(3) Paste attached project files lazarus_dbg.* to (3-ide)

In (0) I have a working lazarus.exe for which the windows shortcut is :
  Target = C:\fpc-laz\Lazarus\3.99_GIT_240829\lazarus.exe --pcp=Config --nsc
Execute above lazarus, maybe adjust paths.

Once in lazarus, tool\configure build lazarus with options
  Clean all checked.
-MObjFPC
-Scghi
-O1
-OoREGVAR
-gw3
-gl
-Xg
 
-OoREGVAR can be omitted but I didn't see that it caused trouble.

If build success, if it didn't restart automatically exit lazarus and reentrer.

Load previously copied lazarus_dbg.lpi, do a simple compile, the project will use the same units that where built in the previous step. (The lazarus_dbg does not automatically compile !).

Depending on the result you may need to adjust C:\fpc-laz\Lazarus\3.99_GIT_240829\ide\staticpackages.inc according to your needs and the lazarus_dbg project parameters in RUN/Run_parameters so it points to the correct config.

Report messages of the built. (Hover on the message of interest with the mouse and hit ctr+c to catch it to the clipboard).

If all goes well you can run the compiled project and from that debug lazarus, you can also run an other application that might interact with the debug lazarus in places of interest.

IF YOU GET THERE NEVER FORGET WHICH instance of lazarus you are in. Its is very easy to be confused ... :-)


Edit : rename lazarus_dbg.lpi.txt to  lazarus_dbg.lpi !
« Last Edit: September 03, 2024, 10:19:00 am by BrunoK »

BrunoK

  • Hero Member
  • *****
  • Posts: 623
  • Retired programmer
Re: Compiling Lazarus
« Reply #5 on: September 03, 2024, 10:21:25 am »
And I use FPDebug

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10561
  • Debugger - SynEdit - and more
    • wiki
Re: Compiling Lazarus
« Reply #6 on: September 03, 2024, 10:39:41 am »
I haven't tried... So I don't know. But maybe the following is one of the puzzle pieces...

If you create your own project, and you add a package, then you make sure that your code contains a "uses some_unit_from_that_package". Or, well, if you don't, then nothing will happen. Adding a package means that the ppu for that package will be build, and that the search path for ppu will include the directory with those ppu. The rest only happens if there is a "uses" clause.

But then if you add e.g. AnchorDocking to the IDE, well you want something to happen. But, as explained, by just adding it to the lazarus.lpi => nothing does happen.
That magic happens in staticpackages.inc, which is $I included in the uses clause of lazarus.pp (or main.pp?). So to build lazarus you need an up to date staticpackges.inc.

And that resides in your pcp (primary config path). Because, depending on install the install dir may not be user-writeable and/or shared between different users with different config.
So to build, the current users pcp must be passed in the right place to get the correct staticpackages.inc.

I guess the lpi does by default not contain such info.


I don't know what other magic bits may be needed, and why (e.g. multi user setup of a single project).
I haven't read that other thread to find what issues it listed.

For the above, if you did not need a lazarus setup shared by multiple users, you could add the include path for staticpackages into your lpi (or move the file into the project dir, and keep it updated there).
And then you could find out what the next problem may be.

Obviously to try that, you have to undo the "no compiler" setting in the lazarus.lpi.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8045
Re: Compiling Lazarus
« Reply #7 on: September 03, 2024, 10:46:03 am »
And that resides in your pcp (primary config path). Because, depending on install the install dir may not be user-writeable and/or shared between different users with different config.
So to build, the current users pcp must be passed in the right place to get the correct staticpackages.inc.

Yes, that's the key bit. Older thread at https://forum.lazarus.freepascal.org/index.php/topic,65706.msg500981.html applies.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

BrunoK

  • Hero Member
  • *****
  • Posts: 623
  • Retired programmer
Re: Compiling Lazarus
« Reply #8 on: September 03, 2024, 11:41:15 am »
But then if you add e.g. AnchorDocking to the IDE, well you want something to happen. But, as explained, by just adding it to the lazarus.lpi => nothing does happen.
That magic happens in staticpackages.inc, which is $I included in the uses clause of lazarus.pp (or main.pp?). So to build lazarus you need an up to date staticpackges.inc.

And that resides in your pcp (primary config path). Because, depending on install the install dir may not be user-writeable and/or shared between different users with different config.
So to build, the current users pcp must be passed in the right place to get the correct staticpackages.inc.
.
.
.
For the above, if you did not need a lazarus setup shared by multiple users, you could add the include path for staticpackages into your lpi (or move the file into the project dir, and keep it updated there).
And then you could find out what the next problem may be.
I restested my "instructions" and noticed that in fact I had moved the staticpackages to my Config_dbg directory but hadn't gone all the way correcting the .lpi.
So here a corrected .lpi where the staticpackages.inc in the project inspector point to the Config_dbg folder.

And the current staticpackages.inc I use in my debug trunk, this must be adapted to your needs.


Quote
Obviously to try that, you have to undo the "no compiler" setting in the lazarus.lpi.
undo the "no compiler"
-->Hence the lazarus_dbg.lpi.

The proof is in the pudding attachment.

440bx

  • Hero Member
  • *****
  • Posts: 4759
Re: Compiling Lazarus
« Reply #9 on: September 03, 2024, 02:25:47 pm »
Thank you all, particularly Bruno for your efforts.  All good information.

Thank you again.

I'll be giving it a try (again) when I'm done with my current project (probably a couple of months away)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018