[Lazarus] Can I configure Lazarus (or the project) to only add symbols on debug?

Bo Berglund bo.berglund at gmail.com
Tue Dec 14 11:55:45 CET 2021

On Tue, 14 Dec 2021 09:29:54 +0100, Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>Thanks, I went there and found where I could add the release mode.

Forgot to say this about my modes creation:

When I only had a Default mode then when I clicked the [..] button there was a
button to the upper left that says "Create Debug and Release modes", which I
used rather than the + button to add a Release mode.
This resulted in two new modes and I could set the Release one as described
before to my liking.

But when I tested the new Debug and Release modes the Debug one worked in a
different way from the Default mode in that it creates two files on compile,
app.exe and app.dbg.
The exe file in this case is not very much different from the release exe in
size, only some 10:s of kb. But the app.dbg file (wich was not present before)
is quite big, larger than the exe file.

Since I did not know what to do about that I removed the Debug mode from the
list and use Default when writing code and test run, then switch to Release to
make the final output.

What did Lazarus do to the Debug mode it created automatically?

I also tested on a RaspberryPi project on an RPi3B (using 2.0.12 + 3.2.0):
In this case I have a service application (non-GUI app), which I basically never
run in the Lazarus debugger. Its mode has never been dealt with so it was the
out-of-the-box default.
Now I added the Release mode by just clicking the + button and naming it
Then I did as before and disbled the "Generate info for the debugger" item.
I also checked the "Strip symbols from executable" box.

The result was a bit surprising:
Using Default
Binary size: 9,572,660 after strip: 4,547,712

Using Release:
Binary size: 6,311,022 after strip: 6,311,020

So in this case the original binary size was a lot larger than the stripped
result from the Default mode, why was this?

And every time I now switch mode for compliling my app it also recompiles the
Indy10 package, why?

Question 2:
Does my action to create the Release mode as a copy of Default using the +
button affect the way the Release mode is actually configured?
On my Windows project discussed earlier I used the "Create Debug and Release
modes" button and then deleted the Debug mode and modified the Release a little
concerning the debug and strip.
And on RPi I used the + button instead, but did the same config on debug

I will need to document this behaviour and note the "correct" way to do it...

Bo Berglund
Developer in Sweden

More information about the lazarus mailing list