# \#dynlink

**URL:** https://discuss.ocaml.org/tag/dynlink/283.md

[Latest](https://discuss.ocaml.org/latest.md) · [Categories](https://discuss.ocaml.org/categories.md) · [Tags](https://discuss.ocaml.org/tags.md)

---

## [Replacing part of a running ocaml program using the Dynlink library](https://discuss.ocaml.org/t/replacing-part-of-a-running-ocaml-program-using-the-dynlink-library/12973)

<div class="topic-metadata">

**Author:** [@Casper\_Schipper](https://discuss.ocaml.org/u/Casper_Schipper)\
**Replies:** 6\
**Last updated:** [September 10, 2023, 10:34am UTC](https://discuss.ocaml.org/t/replacing-part-of-a-running-ocaml-program-using-the-dynlink-library/12973 "2023-09-10T10:34:48Z")

</div>

I am trying to replace (a small part) of my program while it is running using the Dynlink module. I have tried to replicate this example: http://zderadicka.eu/plugins-in-ocaml-with-dynlink-library/ In my code, I have a…

---

## [Dynamic loading of functions](https://discuss.ocaml.org/t/dynamic-loading-of-functions/12748)

<div class="topic-metadata">

**Author:** [@nhuber](https://discuss.ocaml.org/u/nhuber)\
**Replies:** 1\
**Last updated:** [August 8, 2023, 9:37pm UTC](https://discuss.ocaml.org/t/dynamic-loading-of-functions/12748 "2023-08-08T21:37:32Z")

</div>

Hej! I have a more general question regarding dynamic loading of functions. I am implementing a compiler, and I would like to have the ability to also interpret different intermediate representations of my program. The …

---

## [Libraries to link "just in case", such as threads](https://discuss.ocaml.org/t/libraries-to-link-just-in-case-such-as-threads/11366)

<div class="topic-metadata">

**Author:** [@amaro](https://discuss.ocaml.org/u/amaro)\
**Replies:** 0\
**Last updated:** [February 8, 2023, 8:54am UTC](https://discuss.ocaml.org/t/libraries-to-link-just-in-case-such-as-threads/11366 "2023-02-08T08:54:25Z")

</div>

We just noticed that one of Frama-C’s tutorials, which tells users to try bogue on a simple plug-in, is broken due to the lack of threads in the libraries section of our dune file. Frama-C uses dynamic linking for its p…

---

## [Raw ocamlopt commands to create a cmxs file](https://discuss.ocaml.org/t/raw-ocamlopt-commands-to-create-a-cmxs-file/10883)

<div class="topic-metadata">

**Author:** [@rwmjones](https://discuss.ocaml.org/u/rwmjones)\
**Replies:** 4\
**Last updated:** [November 30, 2022, 10:49am UTC](https://discuss.ocaml.org/t/raw-ocamlopt-commands-to-create-a-cmxs-file/10883 "2022-11-30T10:49:01Z")

</div>

I was trying to demonstrate cmxs and native dynamic loading to someone but I cannot come up with the raw commands needed to make a simple example, and I can’t find anyone who has written them down either. NB I do not wa…

---

## [Crazy OCaml dynamic evaluation: is this legal (defined behaviour)?](https://discuss.ocaml.org/t/crazy-ocaml-dynamic-evaluation-is-this-legal-defined-behaviour/10261)

<div class="topic-metadata">

**Author:** [@Gopiandcode](https://discuss.ocaml.org/u/Gopiandcode)\
**Replies:** 10\
**Last updated:** [October 21, 2022, 6:32am UTC](https://discuss.ocaml.org/t/crazy-ocaml-dynamic-evaluation-is-this-legal-defined-behaviour/10261 "2022-10-21T06:32:31Z")

</div>

Note: this is part of some code I’m writing for a research project, so don’t worry about such insanity somehow floating into actual production code :wink: . I’ve been recently working on a project wherein, for various r…

---

## [Dynlink with C stubs when the C external is not used by the library that defines it](https://discuss.ocaml.org/t/dynlink-with-c-stubs-when-the-c-external-is-not-used-by-the-library-that-defines-it/9627)

<div class="topic-metadata">

**Author:** [@thierry-martinez](https://discuss.ocaml.org/u/thierry-martinez)\
**Replies:** 2\
**Last updated:** [April 2, 2022, 11:37am UTC](https://discuss.ocaml.org/t/dynlink-with-c-stubs-when-the-c-external-is-not-used-by-the-library-that-defines-it/9627 "2022-04-02T11:37:13Z")

</div>

I am trying to use Dynlink to load the coq-core.stm package at runtime: let () = Findlib.init (); Dynlink.allow\_unsafe\_modules true; Fl\_dynload.load\_packages ~debug:true \["coq-core.stm"\] The code above succeeds i…

---

## [Dynlink with static binary](https://discuss.ocaml.org/t/dynlink-with-static-binary/8249)

<div class="topic-metadata">

**Author:** [@abate](https://discuss.ocaml.org/u/abate)\
**Replies:** 13\
**Last updated:** [August 5, 2021, 7:47am UTC](https://discuss.ocaml.org/t/dynlink-with-static-binary/8249 "2021-08-05T07:47:28Z")

</div>

hi all. I want to use dynlink with a statically linked binary. my dune file looks like (env (static (flags (:standard -ccopt -static )))) (executable (name main) (libraries dynlink) ;(link\_flags -linkall) I can…

---

## [Dynamic loading a library with Fl\_dynload](https://discuss.ocaml.org/t/dynamic-loading-a-library-with-fl-dynload/7733)

<div class="topic-metadata">

**Author:** [@anwar](https://discuss.ocaml.org/u/anwar)\
**Replies:** 0\
**Last updated:** [April 23, 2021, 7:19pm UTC](https://discuss.ocaml.org/t/dynamic-loading-a-library-with-fl-dynload/7733 "2021-04-23T19:19:20Z")

</div>

I am trying to dynamically load a library (noted as A below) in my non-public application that uses dune as the build tool. I have the following modules: lib: links library A statically register: registers the dynami…

---

## [Dune, dynlink, and undefined symbol](https://discuss.ocaml.org/t/dune-dynlink-and-undefined-symbol/6737)

<div class="topic-metadata">

**Author:** [@sagotch](https://discuss.ocaml.org/u/sagotch)\
**Replies:** 10\
**Last updated:** [November 12, 2020, 1:59pm UTC](https://discuss.ocaml.org/t/dune-dynlink-and-undefined-symbol/6737 "2020-11-12T13:59:50Z")

</div>

Hello. I have this interface for plugins to register plugins in my program: let ht : (string, (string \* (\_ -\> \_ -\> bool))) Hashtbl.t = Hashtbl.create 0 let assets = ref "" let register ~ns m fn = let fn = fn !assets i…

---

## [Using the Dynlink API to re-load code](https://discuss.ocaml.org/t/using-the-dynlink-api-to-re-load-code/6029)

<div class="topic-metadata">

**Author:** [@zbaylin](https://discuss.ocaml.org/u/zbaylin)\
**Replies:** 1\
**Last updated:** [June 25, 2020, 2:50pm UTC](https://discuss.ocaml.org/t/using-the-dynlink-api-to-re-load-code/6029 "2020-06-25T14:50:51Z")

</div>

I’m building a library where it makes sense to be able to have code that can be reloaded at runtime. I was curious if anyone has been able to use the Dynlink library to achieve anything like that? From what I’ve tried …

---

## [Dynlink error: invalid ELF header](https://discuss.ocaml.org/t/dynlink-error-invalid-elf-header/5938)

<div class="topic-metadata">

**Author:** [@maiste](https://discuss.ocaml.org/u/maiste)\
**Replies:** 2\
**Last updated:** [June 8, 2020, 10:12am UTC](https://discuss.ocaml.org/t/dynlink-error-invalid-elf-header/5938 "2020-06-08T10:12:33Z")

</div>

Hi, I’m trying to build a dynamic loader with the Dynlink module. Vg and Gg are opam libraries I want to load. Here is my code: let dynload pkg = let path = Findlib.package\_directory pkg in let file = Format.spri…

---

## [Dynlink works in native mode but not in bytecode?](https://discuss.ocaml.org/t/dynlink-works-in-native-mode-but-not-in-bytecode/3145)

<div class="topic-metadata">

**Author:** [@n4323](https://discuss.ocaml.org/u/n4323)\
**Replies:** 5\
**Last updated:** [January 31, 2019, 8:51pm UTC](https://discuss.ocaml.org/t/dynlink-works-in-native-mode-but-not-in-bytecode/3145 "2019-01-31T20:51:43Z")

</div>

I have the peculiar situation that i can successfully compile and run the native code version of my dynlinked code but not the bytecode version. Who has an idea what I am doing wrong?! I am using the following setup to …
