Compile error - can't find unit FileUtil

Hi CGE-professionals,

I have a problem. I can’t compile in the CGE-Editor because of this error:

But I’m able to compile the program via lazarus and it runs. The Unit “FileUtil” is available. I need this for the function CopyFile();

Who can help?

I think you should specify the path to the FileUtil module in CastleEngineManifest.xml

  <compiler_options>
    <search_paths>
      <path value="/usr/lib64/lazarus/components/lazutils/" />
      <path value="code/" />
    </search_paths>
  </compiler_options>
</project> 

In Windows OS, you will have a different path.

Thanks for this advice. Now CGE compiles without errors. But why should this be necessary for the “FileUtil” unit and not for the other units?

In my case:

grafik

In this case it is not a bug!

1. The simplest advise is that you don’t need FileUtil to copy files. Just use CGE unit CastleFilesUtils with CheckCopyFile routine :slight_smile:

2. To explain why FileUtil is not available out-of-the-box:

The FileUtil unit is not part of the FPC standard library, or CGE units. It is part of Lazarus, more precisely Lazarus LazUtils package.

And CGE in general doesn’t know the path to Lazarus, and doesn’t link to Lazarus units.

While you can solve it as above (adding ...lazutils path to CastleEngineManifest.xml), it is better to rely on lazbuild if you want to build applications that use LCL. For this:

  1. Set build_using_lazbuild="true" in the CastleEngineManifest.xml file (see CastleEngineManifest.xml - Syntax and Examples | Manual | Castle Game Engine , see CGE examples in examples/lazarus/).

  2. Then open your project LPI in Lazarus, and add “LazUtils” package as dependency. You want to make the “Project Inspector” in Lazarus like this:

And that’s it. This way you do not have to hardcode in CastleEngineManifest.xml the location of your Lazarus, because CGE just calls lazbuild and the lazbuild knows the location of Lazarus. In general build_using_lazbuild means that you delegate most of project configuration to Lazarus LPI.