# \[closed\] Compile error - can't find unit FileUtil

**URL:** <https://forum.castle-engine.io/t/closed-compile-error-cant-find-unit-fileutil/714>\
**Category:** Bugs\
**Created:** [January 12, 2023, 10:11am UTC](https://forum.castle-engine.io/t/closed-compile-error-cant-find-unit-fileutil/714 "2023-01-12T10:11:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didi](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/didi/32/1908_2.png) [@Didi](https://forum.castle-engine.io/u/Didi)\
**Post date:** [January 12, 2023, 10:11am UTC](https://forum.castle-engine.io/t/closed-compile-error-cant-find-unit-fileutil/714/1 "2023-01-12T10:11:43Z")

</div>

Hi CGE-professionals,

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

 ![grafik](https://forum.castle-engine.io/uploads/default/original/2X/8/8971ffbd9211ddaf52766a056001af8546b3fea2.png)

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?

---

<div class="post-metadata">

**Author:** ![KumurTash](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/k/b782af/32.png) [@KumurTash](https://forum.castle-engine.io/u/KumurTash)\
**Post date:** [January 12, 2023, 10:41am UTC](https://forum.castle-engine.io/t/closed-compile-error-cant-find-unit-fileutil/714/2 "2023-01-12T10:41:46Z")

</div>

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

```auto
  <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.

---

<div class="post-metadata">

**Author:** ![Didi](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/didi/32/1908_2.png) [@Didi](https://forum.castle-engine.io/u/Didi)\
**Post date:** [January 12, 2023, 11:03am UTC](https://forum.castle-engine.io/t/closed-compile-error-cant-find-unit-fileutil/714/3 "2023-01-12T11:03:50Z")

</div>

> [@KumurTash](#):
>
> FileUtil

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](https://forum.castle-engine.io/uploads/default/original/2X/1/16815bc727671880ca31621cdb267ff77b747d3a.png)

In this case it is not a bug!

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [January 12, 2023, 3:18pm UTC](https://forum.castle-engine.io/t/closed-compile-error-cant-find-unit-fileutil/714/4 "2023-01-12T15:18:41Z")

</div>

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

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](https://castle-engine.io/project_manifest) , 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:

 ![screenshot 2023-01-12 16-14-20 select](https://forum.castle-engine.io/uploads/default/original/2X/4/433163a9bd152cce50bfe49bf6fab1d2683c37a7.png)

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.
