# Where does caml\_copy\_string live?

**URL:** <https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260>\
**Category:** Learning\
**Created:** [December 9, 2017, 7:53pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260 "2017-12-09T19:53:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [December 9, 2017, 7:53pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260/1 "2017-12-09T19:53:58Z")

</div>

`caml_copy_string` is part of the collection of functions for interfacing with C:  
[https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html](https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html)

Is this supposed to be available in utop by default, or at all?

```
# caml_copy_string;;
Error: Unbound value caml_copy_string

```

What do I need to `#require` or `open` to have this available?

I don’t actually want to use this function in utop. I’m just trying to debug a problem with using the `Hdf5_caml` module from the [`hdf5-caml` package](https://github.com/vbrankov/hdf5-ocaml).

I have skimmed the “Interfacing with C” documentation linked above, I haven’t read it thoroughly. It’s not at all obvious whether the answer to my question is there, and since I don’t have a need to interface with C in my own code, I would rather not dive into the details of the documentation just to answer some simple questions. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![techate](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/techate/32/671_2.png) [@techate](https://discuss.ocaml.org/u/techate)\
**Post date:** [December 9, 2017, 8:18pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260/2 "2017-12-09T20:18:02Z")

</div>

It’s defined in caml/alloc.h, a standard include when you write C that will interface with OCaml. Since it’s defined as working on a char const \*, it may not be available in OCaml at all (i.e., there is nothing you can require or open to get it.)

You have better luck asking about your actual problem with hdf5-caml.

---

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [December 9, 2017, 10:44pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260/3 "2017-12-09T22:44:08Z")

</div>

Thanks very much @techate. That’s extremely helpful. It makes sense now that you state it. (I had asked about the error I was getting in an hdf5-caml issue, but the response I got suggested that I shouldn’t get an error when I `#require` `Hdf5_caml`, so I wanted to get a broader understanding of `caml_string_copy` and what might be going on. Perhaps `Hdf5_caml` can only be used in compiled code–not in `utop`–but I’m having trouble with the former as well. But that’s a different issue, I think.)

---

<div class="post-metadata">

**Author:** ![jrzhao42](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jrzhao42/32/620_2.png) [@jrzhao42](https://discuss.ocaml.org/u/jrzhao42)\
**Post date:** [December 11, 2017, 6:49pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260/4 "2017-12-11T18:49:02Z")

</div>

I also have the same issue (OCaml: `4.04.0`, OPAM: `2.0.0~beta`, ). Current I fall back to its `0.1.3` version and it works fine in `utop` so I think it’s quite likely that `Hdf5_caml` is also meant for being used in `utop`.

---

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [December 11, 2017, 8:27pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260/5 "2017-12-11T20:27:37Z")

</div>

> [@jrzhao42](#):
>
> I also have the same issue (OCaml: `4.04.0`, OPAM: `2.0.0~beta`, ). Current I fall back to its `0.1.3` version and it works fine in `utop` so I think it’s quite likely that `Hdf5_caml` is also meant for being used in `utop`.

Good to know it’s not just my configuration. Using 0.1.3 seems like a good solution for now. At this point I’m just trying to learn about `hdf5-ocaml`.

(I have the sense that OCaml users vary in how much they depend on utop. Some people may focus almost exclusively on compiled executables and miss problems in the repl at first. That’s understandable.)

---

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [December 11, 2017, 8:37pm UTC](https://discuss.ocaml.org/t/where-does-caml-copy-string-live/1260/6 "2017-12-11T20:37:24Z")

</div>

vbrankov (`hdf5-ocaml`'s author) said that there’s a bug with strings in 0.1.3, so that version might not be suitable for production work. [https://github.com/vbrankov/hdf5-ocaml/issues/9#issuecomment-350466293](https://github.com/vbrankov/hdf5-ocaml/issues/9#issuecomment-350466293)
