Errors when compiling tcp_connection examples from Lazarus

I am trying to compile
\examples\network\tcp_connection\server\server.lpi
by openning this project from Lazarus.
The complier says:

Cannot find unit CastleVideos used by CastleTextureImages

Then I add path to CastleVideos. Then it complains about unit. This way I have to add almost all paths in /src/
Is there way to do it quicker?
BTW using
castle-engine compile
works just fine. I don’t need to add any paths.
I am trying to use CastleClientServer in my own project in Lazarus.
Creation of a simple project with TCastleControlBase on a Lazarus form - works fine.
But after adding CastleClientServer unit to ‘uses’ brings to CastleVideos not found messages etc.

You should compile the Lazarus packages first, in particular castle_base and castle_window. Lazarus examples use these packages by referring to a name, like castle_base. First you need to (one time) open the 3 packages and compile them. See https://castle-engine.io/documentation.php , " 2. Using Lazarus" section.

If you didn’t do it, but just opened the LPI files, Lazarus most probably showed you an error about missing packages – you must have ignored this error :slight_smile:

Once Lazarus knows the 3 castle_xxx packages, the examples will compile from LPI straight away :slight_smile:

Note: the 2 examples in examples/network/tcp_connection are actually an exception, they require also the Indy package to be installed. See examples/network/tcp_connection/README.md . It’s an exception – in general CGE doesn’t depend on Indy. See also https://castle-engine.io/manual_network.php#section_multi_player .

Note 2: The build tool indeed has a different idea how to find CGE units. It doesn’t look at Lazarus installed packages. Instead it determines CGE directory (e.g. looking at $CASTLE_ENGINE_PATH environment variable) and uses hardcoded paths inside CGE sources to include our units. IOW, it is normal that castle-engine compile worked even if you never opened Lazarus packages.

I know that I have to compile two CGE packages first (base and window) and then install components package. I did it.
Right now: for my project - I added FCL, LazOpsenGLContent, castle_window, castle_base, castle_components, LCL into the list of required packages in Project Inspector.
There are no additional paths on Project Options window.
Then in my project .lpr file I commented:

{, castle_components,
  castle_window, castle_base}  

And it works now for my project. It’s strange that without commenting the compiler says that CastleWindow unit not found. But right now my project work fine - client/sever communication works (I installed Indy correctly before that).

I tried to repeat the same procedure as above on server.lpi - I still cannot compile it with Lazarus (the same missed CastleVideos unit message).

If you need to comment them out to make Lazarus compilation work – that’s strange indeed. When compiling through Lazarus, these units should refer to automatic units that Lazarus creates for each package.

In any case, commenting them out causes no harm. So this is strange, but you can ignore it :slight_smile:

Note that it’s normal that you need to comment them out for the build tool compilation (build tool is not aware of Lazarus automatic units).

I tried to repeat the same procedure as above on server.lpi - I still cannot compile it with Lazarus (the same missed CastleVideos unit message).

Got it, I can reproduce it. A mix with paths – CastleVideos is accidentally accessed directly. I’ll fix it soon.

Fixed!

Thank you for reporting, and very sorry for dismissing your first report as “you probably just didn’t install the packages” :slight_smile: The problem was there all along, I even had a long-forgotten TODO about it. I didn’t realize that it caused compilation to just fail with latest Lazarus.

( Most of the CGE examples are automatically compiled by Jenkins after every commit, so I know they work. But the client/server examples were not checked by Jenkins, as Jenkins doesn’t have Indy installed. I will rectify this too, soon. )

I reorganized things a bit :slight_smile:

We now have castle_indy package (in packages/castle_indy.lpk). It is used by client/server demos, and it should be used in your applications too if you want CastleClientServer unit. This package right now contains only a single unit, CastleClientServer.

And that’s it :slight_smile: New client/server demo from latest CGE should just work. It no longer hardcodes path to CastleClientServer, instead it uses castle_indy package, and compilation is reliable.

I have extended the documentation section about it, https://castle-engine.io/manual_network.php#section_indy .

Note: after updating, you may need to “build clean” to get rid of the confusion with CastleVideos. Use the “Run -> Clean Up and Build…” in Lazarus.

Michalis,
Thank you. I will try.

BTW Before doing my tests I installed Indy using these steps:

  1. I installed Online Package Manager for Lazarus (package name: OnlinePackageManager).
  2. I installed Indy10 package via Online Package Manager. So the exact package name is indylaz.

I have noticed:
For server.lpi - Project Inspector contains path to castleclientserver.pas
I think it should be removed. Because it should find it without such explicit path.
And on Project Options window - Paths:
Other unit files: …\src\files
Include files: …\src\base;$(ProjOutDir)

I think you should ideally remove these paths too. Just leave $(ProjOutDir) for Include files.
Because my project work without these paths to \src
Thus Lazarus must find CGE without these paths.

BTW I understand that you are compiling the examples automatically by Jenkins. Thus you did not have time to manually compile each example using Lazarus. So the problem as stated in my first messages is related to paths and requirements (Required Packages) in Project Options and Project Inspector ( as I think).

For server.lpi - Project Inspector contains path to castleclientserver.pas
I think it should be removed. Because it should find it without such explicit path.
And on Project Options window - Paths:
Other unit files: …\src\files
Include files: …\src\base;$(ProjOutDir)
I think you should ideally remove these paths too. Just leave $(ProjOutDir) for Include files.

Indeed in new CGE version (after my fix this week) the client/server LPI files do not refer to “src\files” or “src\base” paths. They instead use new “castle_indy” package that contains the CastleClientServer in a proper way.

BTW I understand that you are compiling the examples automatically by Jenkins. Thus you did not have time to manually compile each example using Lazarus. So the problem as stated in my first messages is related to paths and requirements (Required Packages) in Project Options and Project Inspector ( as I think).

Jenkins didn’t catch the problem because it was specifically omitting these 2 examples (client/server), as they used Indy and Jenkins didn’t have Indy :slight_smile: I’ll fix it. Then this situation will never happen again, i.e. Jenkins will keep checking that client/server compile with a number of FPC/Lazarus versions.

1 Like