# Fatal error: cannot load shared library dllext\_stubs

**URL:** <https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680>\
**Category:** Learning\
**Tags:** ocamldebug\
**Created:** [May 21, 2025, 1:01pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680 "2025-05-21T13:01:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nojaf](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojaf/32/5587_2.png) [@nojaf](https://discuss.ocaml.org/u/nojaf)\
**Post date:** [May 21, 2025, 1:01pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/1 "2025-05-21T13:01:56Z")

</div>

So, I want to give `ocamldebug` a shot.  
Using latest Mac and OCaml 5.3.0:

```auto
nojaf@nojaf-mbp rescript % dune build
nojaf@nojaf-mbp rescript % ocamldebug _build/default/analysis/bin/main.bc            
        OCaml Debugger version 5.3.0

(ocd) break @Main 92
Loading program... Fatal error: cannot load shared library dllext_stubs
Reason: dlopen(dllext_stubs.so, 0x000A): tried: 'dllext_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllext_stubs.so' (no such file), '/usr/lib/dllext_stubs.so' (no such file, not in dyld cache), 'dllext_stubs.so' (no such file)
(ocd) 

```

Where should `dllext_stubs.dylib` be coming from?

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [May 21, 2025, 1:37pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/2 "2025-05-21T13:37:08Z")

</div>

You can use the environment variable `CAML_LD_LIBRARY_PATH` to specify where to look up shared libraries containing native stubs (see [OCaml - The runtime system (ocamlrun)](https://ocaml.org/manual/5.3/runtime.html)). Dune places the stubs of native (public) libraries in `_build/install/default/lib/stublibs`.

Did you try `dune exec -- ocamldebug ...`?

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![nojaf](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojaf/32/5587_2.png) [@nojaf](https://discuss.ocaml.org/u/nojaf)\
**Post date:** [May 21, 2025, 1:40pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/3 "2025-05-21T13:40:19Z")

</div>

I don’t seem to have any files there:

```auto
nojaf@nojaf-mbp rescript % ls _build/install/default/lib/stublibs
ls: _build/install/default/lib/stublibs: No such file or directory
nojaf@nojaf-mbp rescript % dune exec -- ocamldebug /Users/nojaf/Projects/rescript/_build/default/analysis/bin/main.bc
        OCaml Debugger version 5.3.0

(ocd) break @Main 92
Loading program... Fatal error: cannot load shared library dllext_stubs
Reason: dlopen(dllext_stubs.so, 0x000A): tried: 'dllext_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllext_stubs.so' (no such file), '/usr/lib/dllext_stubs.so' (no such file, not in dyld cache), 'dllext_stubs.so' (no such file)
(ocd) 

```

`CAML_LD_LIBRARY_PATH` rings a bell, but I have no clue where to point it.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [May 21, 2025, 1:43pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/4 "2025-05-21T13:43:29Z")

</div>

Hard to say with the available information. You may want to make your code available somewhere in order to get better advice.

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![nojaf](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojaf/32/5587_2.png) [@nojaf](https://discuss.ocaml.org/u/nojaf)\
**Post date:** [May 21, 2025, 1:45pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/5 "2025-05-21T13:45:04Z")

</div>

Yeah, I understand it is not much to go on.  
The code is available on [GitHub - rescript-lang/rescript: ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript.](https://github.com/rescript-lang/rescript)

It has a few project and I’m trying to debug the `analysis` project.  
Maybe I’m missing some dune flags

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [May 21, 2025, 4:29pm UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/6 "2025-05-21T16:29:24Z")

</div>

> [@nojaf](#):
>
> `CAML_LD_LIBRARY_PATH` rings a bell, but I have no clue where to point it.

I don’t have a Reason toolchain to try it, but a quick look at the source indicates that the missing stubs are those of the library `compiler/ext`. You may want to look into `_build/default/compiler/ext` to see if you find your missing shared library.

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![nojaf](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojaf/32/5587_2.png) [@nojaf](https://discuss.ocaml.org/u/nojaf)\
**Post date:** [May 22, 2025, 6:46am UTC](https://discuss.ocaml.org/t/fatal-error-cannot-load-shared-library-dllext-stubs/16680/7 "2025-05-22T06:46:54Z")

</div>

The Reason toolchain isn’t required here. ReScript compiler is in OCaml, but doesn’t use Reason.  
Could I just be missing a dependency? I think at some point it was inside `_build/default/compiler/ext`. Seems no longer to be the case.

Update:

```auto
ls /Users/nojaf/Projects/rescript/_build/default/compiler/ext/*.so
/Users/nojaf/Projects/rescript/_build/default/compiler/ext/dllext_stubs.so

```

Using `CAML_LD_LIBRARY_PATH=/Users/nojaf/Projects/rescript/_build/default/compiler/ext`:

Now leads to

```auto
Loading program... Fatal error: cannot load shared library dllbase_internalhash_types_stubs
Reason: dlopen(dllbase_internalhash_types_stubs.so, 0x000A): tried: 'dllbase_internalhash_types_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllbase_internalhash_types_stubs.so' (no such file), '/usr/lib/dllbase_internalhash_types_stubs.so' (no such file, not in dyld cache), 'dllbase_internalhash_types_stubs.so' (no such file)
(ocd) %           

```

Okay, I figured it out. I need to append that `_build/default/compiler/ext` path to `CAML_LD_LIBRARY_PATH`

`export CAML_LD_LIBRARY_PATH="$CAML_LD_LIBRARY_PATH:_build/default/compiler/ext"`
