View Full Version : Why Lazarus is rebuilding project each time i run?

28-04-2013, 09:34 AM

I installed latest Lazarus v1.0.8. Fortunately it doesn't crash anymore (XP Pro) like previous version.

I created simple project with empty form and i noticed that each time i run my project it recompiles / rebuilds it.
Even if i don't change anything.
Delphi doesn't do that. It re-compiles only after some changes in project / source were made.
Compiling is slow enough without that, why make it slower.
I just lost 256MB bulk RAM (it just died) and now i have even less RAM in PC and its even slower. So every bit counts.

Is there any way to disable this and make Lazarus smarter?

28-04-2013, 10:01 AM
Project options -> Miscellaneous -> Uncheck "Always build (even if nothing changed)".

It's ok to have unchecked most of the time, but if you change some library files (such as update graphics/game library sources), get new Lazarus from SVN or something, then you may have outdated output folder for your project. It could result a mysterious error message, which you can solve by deleting the whole output folder from the project, or putting this check back temporarily. This will force them to recompile.

You could also try enabling Smart linkable (-CX) and Link smart (-XX) checkboxes to try speed up compilation.

28-04-2013, 11:42 AM
Thanks. That made it a lot faster.

I was looking for such options in IDE settings. Now i know why i didn't find anything.

04-08-2013, 04:57 PM
Didnt want to create new thread.
Installed a Lazarus 1.1 with date of 2013-08-04 and with FPC 2.7.1.
This version because i need generics and stl.

And after creating new project and saving it and then running i always get error and it just stops:

Options changed, recompiling clean with -B
Failed to execute -B -MObjFPC -Scghi -O1 -g -gl -vewnhi -FiC:\Temp2\lib\i386-win32 -FuC:\Temp2\ -FUC:\Temp2\lib\i386-win32\ -l project1.lpr : 2

What it wants from me?

I can use commandline but why IDE fails each time i install 1.1?

04-08-2013, 05:44 PM
Just something to try:
- Tools -> Options: Environment -> Files. Check that all paths point to right places.
- Tools -> Rescan FPC source directory.
- Tools -> Build Lazarus with Profile: Clean Up + Build all.

04-08-2013, 07:53 PM
Tried all 3 options, still same.
Too bad, i wanted to make simple gui app with few buttons to test some algorithm for undo/redo with generics and stl.
But i guess i have to live with console app and command line compiling.

Dunno, if i point some working version of lazarus to fpc 2.7.x instead of "built in version" will it work?

Will install lazarus-1.0.10-fpc-2.6.2-win32 and try again.
Maybe even this will not work.

EDIT: Like expected, v1.0 with 2.6.x works fine.
So its a big bug in Lazarus


Downloaded fpc-2.7.1.i386-win32.zip, created folder called 2.7.1 and extracted all files to this folder. Executed Lazarus and pointed it to this folder. It said something about invalidf paths for make and one about fpc.cfg file is missing or something but i copied it over from 2.6.2 bin folder.
And it works. Lazarus is 1.0.10.
I dont know if this will work with 1.1 but atm im satisfied.
Decided to take the risk and try and to my suprise it compiles successfully.
Generics, stl etc, also available in GUI app.

Looks also much more stable.

Im happy.

05-08-2013, 09:45 PM
In general, when getting strange internal errors that depend on order of compilation:

- reduce inline directives
- reduce unit import cycles.

Specially in combination with generics. This because both inline and generics somewhat live outside the normal "unit" system rules.

While these also matter for Delphi (though after XE that is somewhat reduced), these doubly go for FPC, which will try to inline generic methods in some cases, while Delphi doesn't even try as a rule.

06-08-2013, 08:15 PM
It didnt compile anything, even not the simplest console app or any demos.
Nothing, it even didnt start compiling. Stopped before that.

Its just bug somewhere. I dont have time to debug, i need to work on my projects.

I will remember these tips though.

06-08-2013, 08:53 PM
I will do my best to help if you still need it.

Although I've never understood why so many people have issues with Lazarus, for at least 2 years on multiple machines and multiple platforms fresh installs from the daily SVN snapshots have always worked for me first time. The occasional crash whilst debugging in the early days but no show stoppers.

Just tell it where FPC is, the sources and GDB and it's all hunky dory.

This is all on fresh installs of various Oses and on machines that have been used for years with many installs of lazarus, custom FPC setups etc

I'd love to know what people are doing their machines / installs that causes it to break so utterly. Try a snapshot. Uninstall Lazarus and any FPC you might of installed. Clear any environment variables that may be setting FPC paths etc

Edit : I've not tried the specifc builds you're referring to. Just ignore me. I've not personally had issues with Lazarus.

Also loving generics support in FPC, I'd use them extensively if it wasn't for the fact I've a vast code base with a consistent coding style that already has the things generics make easier, defined. Might go thru my code and replace all the stuff that's applicable with generics one of the days, assuming it doesn't obfuscate things too much.

07-08-2013, 06:06 AM
I started using SVN for both Lazarus and fpc long ago, and can say it didn't come without problems (some fpc 2.7.1 versions are simply incompatible with Lazarus, and i needed to get some version earlier). But it is as you say, all units need their paths. Note, also Windows environment PATH. To compile fpc SVN (2.7.1), version 2.6.0 is required. And to do that, i have to upkeep 2 versions of fpc.cfg and fp.cfg. Both of them include paths such as:

# searchpath for units and other system dependent things
There was some generic symbols at some point i guess, to use some variable, but they never worked for me. And that's as far as Lazarus go.

If you're interested in how i compile fpc SVN, here's the script that does it all in 1 click (i didn't name the folder 2.7.1 because SVN is always latest, and might become 2.8.0 some point, who knows) :

@echo off
REM this batch-file is executed in D:\pascal\fpc\svn\
REM bin\i386-win32\backups contains svn pathed fpc.cfg and fp.cfg

echo Ready to start compiling FreePascal?
echo ---
copy D:\pascal\fpc\2.6.0\bin\i386-win32\*.* D:\pascal\fpc\svn\bin\i386-win32
copy bin\i386-win32\backups\*.* bin\i386-win32

set PATH=D:\pascal\fpc\2.6.0\bin\i386-win32;
make.exe clean distclean
make.exe install INSTALL_PREFIX=D:\pascal\fpc\svn COPYTREE=echo UPXPROG=echo
echo ---
echo All done.
echo ---

11-08-2013, 09:16 AM
Thank you for all the help and tips. I will bookmark these.
I did install fresh XP and then Lazarus and got same error: "Failed to execute -B.."
Pointed it to 2.7.1 folder and all works fine again.

Weird thing is that my copy of 2.7.1 does not contain sources and make.exe, everything else is there.