# JuliaC + HDF5

**URL:** <https://discourse.julialang.org/t/juliac-hdf5/140113>\
**Category:** General Usage\
**Tags:** juliac\
**Created:** [October 20, 2026, 9:42am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113 "2026-10-20T09:42:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [October 20, 2026, 9:42am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/1 "2026-10-20T09:42:20Z")

</div>

I was trying to compile an app using JuliaC and kept getting an error on the `juliac` step. I kept removing everything while keeping the error and until I was left with just one import. Here’s the MVE:

```julia
module Thing

import HDF5

function @main(args)
    println(Core.stdout, "hello")
    return 0
end

end

```

Here’s the error:

```julia-auto
Precompiling packages finished.                   
  1 dependency successfully precompiled in 1 seconds. 60 already precompiled.
◒ Compiling...Error #1: unresolved call from statement !(
  isprecompiling()::Any                                                                                  
)::Any                         
                                                                                                         
Stacktrace:  
 [1] macro expansion     
   @ ~/.julia/packages/Requires/1eCOK/src/require.jl:97 [inlined]                                                                                                                                                  
 [2] __init__ ()
   @ HDF5 ~/.julia/packages/HDF5/Xsdf5/src/HDF5.jl:120
                                                    
Error #2: unresolved call from statement !(
  isprecompiling()::Any    
)::Any                    
                                                    
Stacktrace:               
 [1] macro expansion
   @ ~/.julia/packages/Requires/1eCOK/src/require.jl:97 [inlined]
 [2] __init__ ()
   @ HDF5 ~/.julia/packages/HDF5/Xsdf5/src/HDF5.jl:122

Error #3: unresolved call from statement (f::Any)()::Any

Stacktrace:
 [1] unknown scope
   @ ~/.julia/packages/Requires/1eCOK/src/require.jl:20
 [2] macro expansion
   @ ~/.julia/packages/Requires/1eCOK/src/require.jl:98 [inlined]
 [3] __init__ ()
   @ HDF5 ~/.julia/packages/HDF5/Xsdf5/src/HDF5.jl:120

Error #4: unresolved call from statement push!(
  callbacks(pkg::Base.PkgId)::Any,
  f::Any
)::Any

Stacktrace:
 [1] unknown scope
   @ ~/.julia/packages/Requires/1eCOK/src/require.jl:20
 [2] macro expansion
   @ ~/.julia/packages/Requires/1eCOK/src/require.jl:98 [inlined]
 [3] __init__ ()
   @ HDF5 ~/.julia/packages/HDF5/Xsdf5/src/HDF5.jl:120
Trim verify finished with 4 errors, 0 warnings.
✓ Compiling...
ERROR: Failed to compile Thing
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:44
 [2] compile_products(recipe::JuliaC.ImageRecipe)
   @ JuliaC ~/.julia/packages/JuliaC/CQ4OE/src/compiling.jl:267
 [3] _main_cli(args::Vector{String}; io::Base.TTY)
   @ JuliaC ~/.julia/packages/JuliaC/CQ4OE/src/JuliaC.jl:228
 [4] _main_cli(args::Vector{String})
   @ JuliaC ~/.julia/packages/JuliaC/CQ4OE/src/JuliaC.jl:219
 [5] main(ARGS::Vector{String})
   @ JuliaC ~/.julia/packages/JuliaC/CQ4OE/src/JuliaC.jl:234
 [6] _start()
   @ Base ./client.jl:583
ERROR: failed process: Process(`juliac Thing --output-exe Thing.exe --bundle build --trim`, ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ ./process.jl:610 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base ./process.jl:525
 [3] run(::Cmd)
   @ Base ./process.jl:522
 [4] top-level scope
   @ REPL[2]:1

```

This is in the REPL, I’ve followed this example [Self-contained juliac demonstration](https://discourse.julialang.org/t/self-contained-juliac-demonstration/134366)

```julia-auto
Julia Version 1.13.2
Commit 45b6d15e34b (2026-10-14 20:33 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, haswell)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_PKG_USE_CLI_GIT = true

```

The setup is correct; if I remove the `import` it works.

---

<div class="post-metadata">

**Author:** ![BjarkeHautop](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarkehautop/32/219291_2.png) [@BjarkeHautop](https://discourse.julialang.org/u/BjarkeHautop)\
**Post date:** [October 20, 2026, 9:59am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/2 "2026-10-20T09:59:35Z")

</div>

Sounds like you did with `--trim`, which requires any package you import to be `--trim` compatible. HDF5 isn’t, hence you get that error.

Works fine for me without passing `--trim`.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 20, 2026, 10:12am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/3 "2026-10-20T10:12:56Z")

</div>

See [GitHub - gbaraldi/StaticHDF5.jl: Read and write julia arrays to HDF5 · GitHub](https://github.com/gbaraldi/StaticHDF5.jl) (no idea what the current status of that is though).

---

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [October 20, 2026, 10:20am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/4 "2026-10-20T10:20:45Z")

</div>

You were right. Compiling now.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 20, 2026, 10:45am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/5 "2026-10-20T10:45:08Z")

</div>

HDF5.jl is not currently known to be compatible with `--trim`. I’m the maintainer. StaticHDF5.jl is the current solution.

That said it seems that you getting an error from Requires.jl which HDF5.jl has not used in some time. What version of HDF5.jl are using? What is the output of `using Pkg; Pkg.status()`?

---

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [October 20, 2026, 11:33am UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/6 "2026-10-20T11:33:25Z")

</div>

I no longer have that env, I fixed as soon as someone mentioned `--trim`. Right now I’m on HDF5 0.17.4, but I can’t promise it’s the same that was in that previous env. But generally I try to use latest always.

---

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [October 20, 2026, 1:40pm UTC](https://discourse.julialang.org/t/juliac-hdf5/140113/7 "2026-10-20T13:40:50Z")

</div>

Hey if I may ask a following up…  
I’ve just successfully compiled something.

If used to run

```julia-auto
julia -t 8 --project=. run.jl --arg1 lala

```

Now I’ve checked that

```julia-auto
./mybin --arg1 lala

```

works, but how do I select the number of threads? Is that possible? Or does that get baked into the binary?

EDIT: sorted

```julia-auto
JULIA_NUM_THREADS=8 ./mybin

```
