FPC message: Can not find unit
unit1.pas(40,42) Fatal: Can't find unit forms
The compiler didn't find a compatible forms.ppu file nor a source file (forms.pp or forms.pas or forms.p).
The compiler searches in the unit path. The unit path is the sum of:
- the fpc.cfg file (Linux, Mac OS X, BSD: /etc/fpc.cfg)
- the Lazarus compiler options. See Project -> Compiler Options
- -> Paths -> Other unit files
- -> Inherited -> All inherited options -> unit path (if available)
If using FPC, you can show where it searches for units by adding the -vut options, e.g.
fpc -vut myprogram.pas
Can't find unit interfaces
The 'interfaces' unit is the part of the LCL. You must use it at least once in your program to link in the LCL interface (the platform dependent part of the LCL. For instance gtk or win32). You see this error, if
- Make sure the project uses the LCL package. See Project -> Project Inspector -> Required Packages. If there is no LCL click on the 'Add' button and then 'New Requirement', select the LCL and press Ok;
- Make sure the unit is part of the project. Use Project -> Add editor file to project;
- Make sure the 'interfaces.ppu' is in the unit path, and the 'interfaces.pp' is not in the unit path. And that you only have one 'interfaces.ppu' in the unit path. You can see the unit path in Source Editor -> Right mouse click -> File Settings ... -> Unit Info -> Unit Paths;
- Make sure your compiled LCL fits to the installed compiler. For example if you installed a new compiler, then the LCL must be rebuilt (for example the interfaces.ppu must be rebuilt (You must be loged in as admin to rebuild) );
- Make sure the project compiles the correct (current) widgetset. See Project -> Compiler Options -> Path -> LCL Widget Type (various). Change it to "default (*****)" to use default widgetset. If you don't want compiles with default widgetset, then change this value to any value, and recompile LCL to respective widgetset (win32/win64, gtk, gtk2, etc).
- Make sure the project compiles the correct "Target CPU". See "Project -> Compiler Options -> Code -> Target CPU (-P)" and change them to (Default) (or in blank).
Can't find unit LResources
Can be solved by doing "Tools/Build Lazarus"
Can't find unit System
This often happens with console IDE on Ubuntu systems. To fix it, follow this solution.
Also maybe you're trying compile your project to other "Target OS". See "Project -> Project Options -> Compiler Options -> Code generation -> Target OS (-T)" and change them to (Default) (or in blank).
Detailed description about this topic
There is a detailed page about searching units here: Unit not found - How to find units