garrigue / lablgtk

LablGTK 2 and 3: an interface to the GIMP Tool Kit
https://garrigue.github.io/lablgtk
Other
90 stars 40 forks source link

Running bytecode executable with ocamlrun crashes: "Fatal error: unknown C primitive `ml_gtk_stack_add_named'" #135

Closed hugrs closed 2 years ago

hugrs commented 3 years ago

When I run any program that uses lablgtk with ocamlrun I get this error:

> ocamlrun ../_build/default/lablgtk/examples/tooltip.bc
Fatal error: unknown C primitive `ml_gtk_stack_add_named'
fish : Tâche , 'ocamlrun ../_build/default/labl…' terminée par le signal SIGABRT (Abandon)
>

Now I'm a bit embarrassed because I believe this was introduced in my pull request, which was commit 1aa358238b0f43efdd287f5d1d9bef81a4ae8b53.

Here is how I reproduce it on my computer: I'm using one of the examples for demonstration.

hugo ~/Bur/mgp/lablgtk ((034d4fbb…))> git checkout 1aa358238b0f43efdd287f5d1d9bef81a4ae8b53
HEAD est maintenant sur 1aa35823 Add bindings for GtkStack and GtkStackSwitcher (#122)
hugo ~/Bur/mgp/lablgtk ((1aa35823…))> dune clean && dune build @all
....
hugo ~/Bur/mgp/lablgtk ((1aa35823…))> ocamlrun ../_build/default/lablgtk/examples/tooltip.bc
Fatal error: unknown C primitive `ml_gtk_stack_add_named'
fish : Tâche , 'ocamlrun ../_build/default/labl…' terminée par le signal SIGABRT (Abandon)
hugo ~/Bur/mgp/lablgtk ((1aa35823…)) [SIGABRT]> 

For comparison, the problem doesn't occur if I switch to the commit right before that (034d4fbb1f09431048dd4231bf2ba9c69db59e6a)

~/Bur/mgp/lablgtk (lablgtk3)> git checkout 034d4fbb1f09431048dd4231bf2ba9c69db59e6a
HEAD est maintenant sur 034d4fbb Fix #116 : problem with GPack.layout adjustments
hugo ~/Bur/mgp/lablgtk ((034d4fbb…))> dune clean && dune build @all
hugo ~/Bur/mgp/lablgtk ((034d4fbb…))> ocamlrun ../_build/default/lablgtk/examples/tooltip.bc
// Runs properly

I'd be happy to help solving it but sadly I don't understand why this happens. If this helps I'm running Linux Mint 20.04.

ejgallego commented 2 years ago

This is due to not having setup OCaml ld's patch correctly, you can use dune exec for that:

dune exec -- examples/tooltip.bc

works.