April 18, 2011
While analyzing the traffic to this site I was surprised to see that still so many Lazarus users are asking Google for a solution for their problems with the lresources and interfaces units. Reason enough to spend an article on the issue.
Both units are part of the Lazarus Component Library (LCL). This is a Lazarus-package which contains the units with all the classes to create GUI applications.
The problem with this package is that it has something special that no other package has: it has been split up for different widgetsets. As soon as the 'interfaces' unit is included into your project, it is linked to such a widgetset.
By widgetset the Lazarus developers mean a collection of graphical controls which you can use to build applications. You can select which set of controls you want to use. On Windows almost everone uses the controls which are part of the Windows API. But you could also use the controls from QT, GTK or Carbon/cocoa on OS/X.
Before you can use these controls, the LCL has to be compiled for the widgetset you have chosen. And, but this holds for all units, the unit has to be compiled by the same Free Pascal compiler version and for the same combination of CPU and OS (target) as your application.
So when you encounter the error message 'Can't find unit interfaces used by ...', you have to make sure that the LCL is compiled for the same compiler version (and thus also the versions of the RTL and FCL), CPU, OS and widgetset. Besides that the compiler has to be able to find the compiled units from the LCL.
First thing to check are the project-settings. Make sure that your project has the 'LCL' as a required package, or else it will be unable to find the units. You can check this in the Project Inspector. Second step is to find out for which widgetset you are compiling. This can be found in the Project Options, on the 'Compiler options' section. The widgetset is set there as the 'LCL Widget Type'. Note that the widget type is something different then the operating system you are compiling for. This can be confusing on Windows, because the default widgetset there is 'win32/win64' while the operating system (in the 'code generation' section of the project options) is 'Win32' or 'Win64'.
As an extra safety check also check whether the right compiler-executable and Lazarus-directory are used. These two settings can be found in the 'Environment' section of the 'Environment/IDE options'.
If there are no problem with the above settings and the problem does still persist, it could be that the LCL is simply never compiled for the current combination of widgetset,OS and CPU. It could also be that the compiled units are out-of-date because another version of the Free Pascal compiler is used. Or there have been some changes in some Free Pascal units in the LCL or RTL. In all these cases the solution is to recompile the LCL.
Recompiling the LCL sounds difficult, but it isn't. Just go to 'Tools'/'Configure build Lazarus'. Select the 'Build LCL' profile to only build the LCL. If you want to, you can also choose to recompile the complete IDE, but to solve the 'can't find unit interfaces' problem recompilation of the LCL is enough. Make sure the correct widget type, OS and CPU are selected and choose 'build'.
In some cases you do not have the right to write to the location where the compiled LCL units are stored. In that case you won't be able to compile the LCL. Log in as an user who has these rights and try again.
For new users this might seem a lot of work, and one may wonder if it really has to be that difficult. But do not forget that other development environments like Delphi only support one type of widgets while Lazarus supports several. This is a nice feature but it comes at a cost. On the other hand you can see that Lazarus evolves and that the developers try to minimize problems like these. In the current development version 0.9.31 the LCL is no longer a special package, but a normal package. You can select the widgetset you want to use with a simple define or macro. The big advantage of this approach is that when you compile your application, the IDE tries to detect if the LCL is compiled for the used target and/or widgetset. If this is not the case the LCL will be re-compiled automatically, just like it is done for other packages. Hopefully this will solve this problem once and for all.
Your email adress will not be published. The required fields are marked by *
Java-bytecode target added to the Free Pascal compiler.
August 20, 2011
A new target has been added to Free Pascal compiler. It is now possible to compile applications to Java bytecode. This means that these Free Pascal applications can run in a Java Virtual Machine (JVM), so that it can run on any platform that has Java support.
Dutch Pascal conference 2011.
June 12, 2011
After the success from last year, the Dutch Pascal Users Group organizes the second Dutch Pascal Conference on June 18th. Last year it was mainly focused on Lazarus, this year there will also be some topics about Delphi.
-- Zeljan Rikalo