Lazarus component installation from Castle Editor doesn't seem to work

I have to admit I’m not very happy that CGE development is so heavily geared towards Castle Editor. I know that it is possible to develop without it but the examples given lately also foresee its use and I just have to adapt to it. I removed CGE and followed the steps suggested by the new manual instructions. When I click on Register Lazarus Packages the operation seems to be successful but when I open Lazarus no components are installed. Clicking in the editor on Open Project in Code Editor raises Failed to Execute error: 740. Suggestions?

We advise using CGE editor, because it allows to visually design CGE components (UI, 3D / 2D game world) which was simply not possible before. We definitely want to go in this direction, as it opens up possibilities not available without the editor :slight_smile: Things that were time-consuming to set up earlier, are now sometimes trivial to set up in a few clicks.

And the CGE components designed this way work on all our platforms (desktop, mobile, Switch, upcoming WebGL), in really cross-platform way (not a single line of code needed to account for differences between desktop / mobile / Switch in typical games). And we are not limited to platforms supported by LCL this way.

So we definitely want to go with editor. I’m not saying that it’s perfect, there’s work ahead to make it better and better, but it’s a huge step towards easily making games in CGE. This is also the way all game engines go, it seems – people expect now to visually design stuff, not only set everything from code, because for some tasks this is just more efficient.

Note that using CGE editor you can design controls that work both in TCastleControlBase and TCastleWindowBase. So you can always put CGE rendering inside LCL controls.

But to be clear, you are not forced to use the editor. But we do advise it heavily, as for many things (like designing normal UI) doing it without CGE editor would be just a lot of painful work. But you can always instantiate everything from code, and you can use both TCastleControlBase and TCastleWindowBase, nothing about it changed in CGE since years.

The “Register Lazarus Packages” does the registration of packages in Lazarus. It doesn’t recompile Lazarus, so the TCastleControlBase will not automatically appear in the component palette.

For this, follow the documentation – Engine control to put on Lazarus form. Also linked from recent news, New manual chapter that introduces editor and states, more manual and website updates, “Register Lazarus Packages” button – Castle Game Engine . That is, install castle_components.lpk, exactly as you did with previous engine versions.

So, really nothing changed here, if you want to use TCastleControlBase, you can still do it, using exactly the same procedure as before.

Please show a screenshot. This is quite cryptic message, I absolutely want to fix it :slight_smile: Is there anything more displayed?

Or what operating system does it happen? Windows, Linux? I just retested this on both Windows and Linux with various Lazarus versions installed from fpcupdeluxe and it works OK.

Do you have Lazarus path properly configured? What is visible in editor “Preferences → FPC and Lazarus”?

Finally, please attach the editor log after such failure. You can find the log in c:/Users/<username>/AppData/Local/castle-editor/castle-editor.log (the location may differ somewhat between Windows versions) or $HOME/.config/castle-editor/castle-editor.log (on Linux).

OK! I got it :slightly_smiling_face:


Fixed up :slightly_smiling_face:
I am attaching a screenshot anyway but looking at the log file I realized that the editor did not have the writing privileges. In my case I solved it by running the editor in Administrator mode (on windows 10).


1 Like

Aha, OK! Looking at source code, the cryptic “Failed to execute : 740” is from FPC implementation of TProcess on Windows (fcl-process/src/win/ They do Raise EProcess.CreateFmt(SErrCannotExecute,[FCommandLine,GetLastError]); and

  • FCommandLine is empty (I guess because TProcess.CommandLine got deprecated some time ago, in favor of TProcess.Parameters list (and from CGE we indeed use new, non-deprecated TProcess.Parameters))

  • and for some reason they just show an error number, not String message (I think SysErrorMessage would give the right message).

So we end up with cryptic “Failed to execute : 740”. Fixing this would require a fix from FPC side (do you want to submit a report to them?), to use WCommandLine and SysErrorMessage.

Looking at Windows codes, 740 is

740 (0x2E4)
The requested operation requires elevation.

( System Error Codes (500-999) (WinError.h) - Win32 apps | Microsoft Docs ). It seems we didn’t have permissions to execute Lazarus. So this matches your finding. So error message was right, albeit cryptic.

I would recommend that, instead of “elevating” the CGE editor privileges, you fix the Lazarus privileges. For some reason, your Lazarus can be executed only by administrator, at least the WinAPI used by TProcess behaves like it. For security, it’s better to not run “normal” applications with admin privileges.

I don’t know if I understand your suggestion correctly but currently Lazarus is already set up to be started as an administrator. As a further clue the CGE folder is in the Lazarus root. However, if I don’t start the Editor as administrator, error 740 is raised.

My suggestion was to rather go the other direction – set up Lazarus such that it does not have to be run by the administrator. So relax some Lazarus folder/files permissions. In general, neither Lazarus nor CGE editor should be run as administrator.

This is more secure, in case there’s a security bug in either Lazarus or CGE editor.

Anyway, it probably doesn’t matter in practice :slight_smile: If you open mostly your own projects. And I haven’t heard of any real-life attack where someone was preparing a specially-crafted Lazarus project to hack developer’s machine. But I’m just pointing out “best practices for security”.