Recent

Author Topic: Compiling lazarus  (Read 7150 times)

duzenko

  • New Member
  • *
  • Posts: 41
Compiling lazarus
« on: January 10, 2022, 09:17:01 am »
(BTW What is the right forum to discuss this?)

1. How are we supposed to run the compiled binaries?
By default it seems to put the .exe into the source code folder.
I think it's not the desired effect, as we should not have the source files and runtime files in the same heap.
Is there a make flag to set the output folder?
Should we copy the lazarus installation inside the source folder somewhere?

2. How can I debug fpdebug? E.g. TProcessDebugger.ProcessRun
« Last Edit: January 10, 2022, 09:28:32 am by duzenko »

balazsszekely

  • Guest
Re: Compiling lazarus
« Reply #1 on: January 10, 2022, 09:28:22 am »
@duzenko
Quote
Is there a make flag to set the output folder?
Lazarus Menu->Project->Project Options->Compiler Options-Paths->Target File Name(see attached image).

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #2 on: January 10, 2022, 09:29:18 am »
You mean to compile lazarus from inside lazarus? It does not work at all and wiki says we need to compile from console

balazsszekely

  • Guest
Re: Compiling lazarus
« Reply #3 on: January 10, 2022, 09:42:33 am »
@duzenko
Sorry, my mistake. You were talking about the IDE.
1. The sources are in $(LazarusDir)\IDE
2. The binaries by default are put in $(LazarusDir) folder
3. You can rebuild the IDE via Tools->Build Lazarus with profile ... or via a script
4. You can debug the IDE by opening  $(LazarusDir)\IDE\lazrus.lpi and running the project
4. IIRC the destination directory is configurable in one of the makefile

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #4 on: January 10, 2022, 09:56:46 am »
4. You can debug the IDE by opening  $(LazarusDir)\IDE\lazrus.lpi and running the project

Could you guide me here?
I have loaded the lazarus.lpi, opened ProcessDebugger.pp, put cursor on line 142, then menu - Go to cursor
Debugger tries to start, but the lazarus GUI does not show, instead the assembler debug window pops up


duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #5 on: January 10, 2022, 10:16:26 am »
If I run the project via F9 then all breakpoints get disabled
E.g. in TAboutForm.FormShow

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #6 on: January 10, 2022, 10:20:49 am »
Note that I have previously compiled lazarus from console
If I delete the .exe and try to compile from IDE, I get this error

[Window Title]
Nothing to do

[Content]
The project's compiler options has no compile command.
See Project / Compiler Options ... / Compilation

[Cancel] [Ignore]

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Compiling lazarus
« Reply #7 on: January 10, 2022, 03:28:42 pm »
To debug lazarus, open the project "ide/lazarus.lpi"

To compile lazarus use: Tools > Configure build Lazarus.
(Using compile or build for "ide/lazarus.lpi" does not work).

The "Configure build Lazarus" allows you to add options for the compilation.
For debugging
-O- -gw3 -gt -gh -gl -Criot -Sa -Si-

Optionally: -O-1
And if you debug with gdb instead of fpdebug, then instead of "-gw3" use: -gw -godwarfwithsets

Most packages follow the IDE compile settings  (FpDebug and LazDebuggerFp do).
For any package that does not, you need to apply the setting in the package's options.

If you want to debug FpDebug, open the files, and enable the {$INLINE off} at the top of each file.



After you compiled (depends on your OS and on write permissions to the install folder):

Check for "lazarus.new.exe".
Normally the IDE will rename the existing exe to ".old", but if that fails it compiles the new exe to a new name.

Then you need to restart the IDE to get the files renamed correctly.

Otherwise you can start the newly compiled exe, in the debugger, without needing to restart.

Or you can add an option to the compile settings, to create the exe with a completely diff name.
Then you need to adapt the project file, so the exe with your chosen name is run. (I never done that / so don't have details on this particular idea)

On linux, the new exe may be created in the "primary conf path" ~/.lazarus/
I have not tested on Linux, not sure if the "ide/lazarus.lpi" will start the exe from the installer or the PCP, when you press F9.




Well and once you build the exe, you can use "ide/lazarus.lpi" to debug it like any other project.

You may wont to open "Run params" from the run menu. Then you can add command line parameters for the "debug target IDE".
You can give it --primary-config-path=/home/NAME/.laz2conf
- And there you can make changes affecting only the debug target. (e.g. change the editor background or gutter color, so you know which editor belongs to which IDE).
- Also with this, different window locations (once you move them) are stored for your real IDE and your "debug target IDE".

And yes, you can debug some project inside your "debug target IDE". So that then your outer-most IDE, can debug the debugger in the "debug target IDE" while that debugger is debugging some project.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Compiling lazarus
« Reply #8 on: January 10, 2022, 03:31:40 pm »
TProcessDebugger.ProcessRun

TProcessDebugger is "run without debugging".




Ideally you should set up a Lazarus from "git main" (daily development version).

For that you need to "git clone" our repo. There is a wiki page on that (IIRC "install from sources"). Not sure of the url.
For windows maybe: https://wiki.lazarus.freepascal.org/Installing_Lazarus_on_Windows => still  svn though, that is no longer correct.

And well, yes. There are changes to the debugger in git main already.


Btw: Your OS?
« Last Edit: January 10, 2022, 04:02:21 pm by Martin_fr »

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #9 on: January 10, 2022, 04:06:28 pm »
@Martin_fr
That works with some pain
However I'm not sure how I am supposed to generally use the version built from gitlab
The checked out version does not have fpc, gdb, etc
Do I need to check it out into the 'normal' directory or ???

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #10 on: January 10, 2022, 04:23:38 pm »
Also, the compiled binary in the git folder only has gdb debugger option

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: Compiling lazarus
« Reply #11 on: January 10, 2022, 05:13:03 pm »
You can make it a secondary install. So it is independent of your main install.
https://wiki.lazarus.freepascal.org/Installing_Lazarus_on_Windows#Multiple_Lazarus_installs

You can point it to use the FPC from your main install.
Do not copy the FPC folder. Or if you do, make sure to update the file "fpc.cfg".
Or install an FPC of your choice.

Same for GDB. Or download from our Sourceforge site.

* only gdb debugger.
- You probably just did "make". If you did "make bigide" it should be there.
- On windows the easiest way to build, is to copy an existing lazarus.exe, and the build from the menu.
   (Though that breaks every now and then / every few years / and it does break right this week...)

In any case, now that you have a lazarus.exe you can use this.
- Menu: Packages > Install Packages ==> add LazDebuggerFp
  and if you are there, also add: Cody, LazDebuggerFpGdbmi, TurboPowerIProDsgn (if it is not installed already)
   (any LazDebugger* - you may not need them, but that way you know if any change you make breaks them)
- Then rebuild the IDE.

If you get an error about LazDebuggerIntf or IdeDebugger unit missing => as I said, every now and then it breaks (new build in dependency....)
=> go to package > install package, and install the 2 packages too (or do it before you even try to rebuild).
  If there are not listed (they should be, but sometimes...),  menu Package > Open Package from file  (ide/packages/idedebugger ; components/LazDebuggers/LazDebuggerIntf). Once you had them open, they will appear in the install list.

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #12 on: January 15, 2022, 06:46:57 am »
Hi, I have a problem with compiling again
I'm on latest git
Trying to make from command line results in

Code: Pascal  [Select][+][-]
  1. (10028) Recompiling Debugger, checksum changed for C:\dev\lazarus_src\components\debuggerintf\lib\i386-win32\dbgintfdebuggerbase.ppu
  2. C:\dev\lazarus_src\ide\environmentopts.pp(55,50) Fatal: (10022) Can't find unit Debugger used by EnvironmentOpts
  3. Fatal: (1018) Compilation aborted

Lazarus GUI rebuild seems to give no errors but breakpoints are disabled and self-debugging does not work

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #13 on: January 15, 2022, 07:22:15 am »
Another issue is I can't add FpDebug to compiled lazarus
Do I need copy and paste the fpc folder from my 2.2 install to the sources folder?

duzenko

  • New Member
  • *
  • Posts: 41
Re: Compiling lazarus
« Reply #14 on: January 18, 2022, 05:50:19 am »
@Martin_fr

bump

 

TinyPortal © 2005-2018