# "not a bytecode file" error message in ocamldebug

**URL:** <https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459>\
**Category:** Learning\
**Created:** [June 22, 2017, 4:10pm UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459 "2017-06-22T16:10:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathandoyle](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jonathandoyle](https://discuss.ocaml.org/u/jonathandoyle)\
**Post date:** [June 22, 2017, 4:10pm UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459/1 "2017-06-22T16:10:14Z")

</div>

Here is my short sequence of commands :

> $ ocamlc -bin-annot -g str.cma unix.cma -o debugger.d.cmo -c debugger.ml  
> $ ocamlopt -bin-annot -g str.cmxa unix.cmxa -o debugger.ocaml\_debuggable  
> $ ocamldebug debugger.ocaml\_debuggable  
> OCaml Debugger version 4.04.1  
> (ocd) break @debugger 6291  
> Loading program… /Users/jonathandoyle/Documents/OCaml/Idaho/debugger.ocaml\_debuggable is not a bytecode file.

What did I do wrong ?

---

<div class="post-metadata">

**Author:** ![antron](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/antron/32/62_2.png) [@antron](https://discuss.ocaml.org/u/antron)\
**Post date:** [June 22, 2017, 7:50pm UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459/2 "2017-06-22T19:50:46Z")

</div>

I don’t use `ocamldebug`, but the manual implies that it [only accepts bytecode executables](http://caml.inria.fr/pub/docs/manual-ocaml/debugger.html#sec360). That means you shouldn’t be creating `debugger.ocaml_debuggable` with `ocamlopt`, but with `ocamlc`.

---

<div class="post-metadata">

**Author:** ![jonathandoyle](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jonathandoyle](https://discuss.ocaml.org/u/jonathandoyle)\
**Post date:** [June 23, 2017, 11:55am UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459/3 "2017-06-23T11:55:47Z")

</div>

> [@antron](#):
>
> That means you shouldn’t be creating `debugger.ocaml_debuggable` with `ocamlopt`, but with `ocamlc`.

I used `ocamlc` in place in `ocamlopt`and it works now, thank you.

I am surprised though that the `-g` option exists for `ocamlopt` (and is even mentioned in the manual) as it seems to serve no purpose

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [June 23, 2017, 12:41pm UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459/4 "2017-06-23T12:41:52Z")

</div>

> [@jonathandoyle](#):
>
> I am surprised though that the -g option exists for ocamlopt (and is even mentioned in the manual) as it seems to serve no purpose

It does. Retains symbol names which are needed for the stack traces (and native debugging in general). See the [manual](http://caml.inria.fr/pub/docs/manual-ocaml/native.html#sec287).

---

<div class="post-metadata">

**Author:** ![jonathandoyle](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jonathandoyle](https://discuss.ocaml.org/u/jonathandoyle)\
**Post date:** [June 23, 2017, 12:44pm UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459/5 "2017-06-23T12:44:01Z")

</div>

> [@dbuenzli](#):
>
> It does. Retains symbol names which are needed for the stack traces (and native debugging in general). See the [manual](http://caml.inria.fr/pub/docs/manual-ocaml/native.html#sec287).

If I understood correctly, native debugging cannot use `ocamldebug`. How does one do it then ? Is it via gdb ?

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [June 23, 2017, 1:06pm UTC](https://discuss.ocaml.org/t/not-a-bytecode-file-error-message-in-ocamldebug/459/6 "2017-06-23T13:06:06Z")

</div>

> [@jonathandoyle](#):
>
> How does one do it then ? Is it via gdb ?

Maybe soon with [first class support](https://github.com/ocaml/ocaml/pull/574). But it’s already useful to have the names in C backtraces and for other C profiling tools in general.
