# How to pre-compile an extension?

**URL:** <https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 27, 2024, 12:40pm UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160 "2024-11-27T12:40:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 27, 2024, 12:40pm UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160/1 "2024-11-27T12:40:08Z")

</div>

How can I precompile “RatiosFixedPointNumbersExt”?

I have a script that creates a system image, and if I run Julia with this system image I do not want that it starts precompiling again, it should be instant, but if I run one of my examples it starts precompiling this extension.

I don’t even know to which package this extension belongs.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [November 27, 2024, 1:25pm UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160/2 "2024-11-27T13:25:10Z")

</div>

It seems to come from Ratios.jl:

> <https://github.com/timholy/Ratios.jl/blob/master/ext/RatiosFixedPointNumbersExt.jl>

I guess you could open an issue there so that the dev adds a PrecompileTools.jl workload.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [November 27, 2024, 10:20pm UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160/3 "2024-11-27T22:20:07Z")

</div>

> [@ufechner7](#):
>
> I have a script that creates a system image,

Does your script load both `Ratios` and `FixedPointNumbers`? If so, I would have expected the extension to be automatically precompiled (maybe not with an optimal workload, though)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 27, 2024, 10:34pm UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160/4 "2024-11-27T22:34:07Z")

</div>

> [@ffevotte](#):
>
> `Ratios` and `FixedPointNumbers`

No, at least not directly: [KiteModels.jl/Project.toml at main · ufechner7/KiteModels.jl · GitHub](https://github.com/ufechner7/KiteModels.jl/blob/main/Project.toml)

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [November 27, 2024, 10:48pm UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160/5 "2024-11-27T22:48:40Z")

</div>

> [@ufechner7](#):
>
> No, at least not directly

OK, so this might be part of the problem.

```julia
(KiteModels) pkg> why Ratios
  Interpolations → Ratios

(KiteModels) pkg> why FixedPointNumbers
ERROR: The following package names could not be resolved:
 * FixedPointNumbers (not found in project or manifest)

```

`KiteModels` does load `Ratios` (as an indirect dependency via `Interpolations`), but apparently not `FixedPointNumbers`. Could it be that he latter is loaded via an extra dependency in the example script that causes the unwanted precompilation?

Could you maybe load that other dependency when you build the sysimage? I think it would ensure that the sysimage at least knows about `FixedPointNumbers` and `RatiosFixedPointNumbersExt`.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 28, 2024, 2:35am UTC](https://discourse.julialang.org/t/how-to-pre-compile-an-extension/123160/6 "2024-11-28T02:35:50Z")

</div>

```julia
julia> using TestEnv

julia> TestEnv.activate()
"/tmp/jl_nbPzwo/Project.toml"

(jl_nbPzwo) pkg> why FixedPointNumbers
  ControlPlots → PyPlot → Colors → ColorTypes → FixedPointNumbers
  ControlPlots → PyPlot → Colors → FixedPointNumbers

```

I use the test environment for my examples. I will add Colors to the system image.
