2

On Fedora 21, I compiled the Frama-C Aluminum distribution from source after installing all its prerequisites. My version of OCaml is 4.02.3. Frama-C and the Frama-C GUI work fine. I am trying to follow section 2.3, "The ViewCfg plug-in" of the Frama-C Plug-In Development Guide. However, in section 2.3.4, "Extending the Frama-C GUI", after I add the GUI extension code and run it using the "-load-script" option, I get the following message:

File "cfg_print.ml", line 87, characters 19-43:
Error: Unbound module GMenu
[kernel] user error: compilation of 'cfg_print.ml' failed

Lines 86-87 read:

let cfg_selector
    (popup_factory:GMenu.menu GMenu.factory) main_ui ~button:_ localizable =

I googled "unbound module gmenu" but didn't find anything useful. I also never ran into this error while using the Neon and Sodium versions of Frama-C. Interestingly, if I skip that section and follow section 2.3.5, "Splitting files and writing a Makefile", I no longer get the "Unbound module GMenu" message, and the example works fine.

If I had to guess, when I use the "-load-script" option, Frama-C (or my version of OCaml, whatever the case may be) apparently cannot find the Gtk libraries for some reason. But if I use make, OCaml can find the Gtk libraries. Is there something possibly wrong with the way I installed Frama-C and/or the Gtk libraries? How can I check this, or more importantly, how can I fix this?

gsp
  • 67
  • 1
  • 5

1 Answers1

2

Your Frama-C installation is probably ok. What you observe is a bug that was introduced when we transitioned to OCamlfind. We will fix it for Frama-C Silicium.

In case you really want to use a script, here is the patch that you need to apply to the sources of Frama-C:

--- a/src/kernel_services/plugin_entry_points/dynamic.ml
+++ b/src/kernel_services/plugin_entry_points/dynamic.ml
@@ -236,7 +236,7 @@ let load_script base =
     else
       Format.fprintf fmt "%s -c" Config.ocamlc ;
     Format.fprintf fmt " -w Ly -warn-error A -I %s" Config.libdir ;
-    if !Config.is_gui then Format.pp_print_string fmt " -I +lablgtk" ;
+    if !Config.is_gui then Format.pp_print_string fmt " -package lablgtk2" ;
     List.iter (fun p -> Format.fprintf fmt " -I %s" p) !load_path ;
     Format.fprintf fmt " %s.ml" base ;
     Format.pp_print_flush fmt () ;
byako
  • 3,372
  • 2
  • 21
  • 36
  • Now I'm getting "ocamlopt.opt: unknown option '-package'." followed by a list of ocamlopt options. Any idea what's wrong now? – gsp Aug 02 '16 at 02:44
  • This is strange: `ocamlopt.opt` should never be called. Instead, `ocamlfind ocaml` should be used. Is ocamlfind installed and used to compile Frama-C. (It should, but one never knows.) – byako Aug 02 '16 at 12:35
  • Ocamlfind is installed. I just used `./configure && make && sudo make install` to compile & install Frama-C, but unfortunately I did not save the output, so I don't know whether ocamlfind was used to compile Frama-C. I do still have config.log. Would that help? – gsp Aug 02 '16 at 19:59
  • I was actually able to get it to work by manually editing dynamic.ml myself and hard-coding `ocamlfind ocamlopt` in there, but I imagine that's not the best way to fix it. It's fine for me for now until you guys release the next version of Frama-C. – gsp Aug 02 '16 at 20:05
  • Both `share/Makefile.config` and `config.ml` should contain `ocamlfind ocaml` and `ocamlfind ocamlopt` for the respective variables. If one (or both) contain(s) something else, there is a bug somewhere. Your `config.log` would probably help, indeed. But first, what do the commands `ocamlfind` and `ocamlfind ocamlopt -where` produce? – byako Aug 03 '16 at 11:48
  • My `share/Makefile.config` has `OCAMLC ?=ocamlc.opt` and `OCAMLOPT ?=ocamlopt.opt`. `config.ml` has `let ocamlc = "ocamlc.opt"` and `let ocamlopt = "ocamlopt.opt"`.The output of `ocamlfind` is the "Usage" output. The output of `ocamlfind ocamlopt -where` is `/usr/lib64/ocaml`. Maybe I installed ocamlfind incorrectly somehow? – gsp Aug 03 '16 at 19:23
  • My advice was actually not that good, because I mixed up Aluminium and the development version of Frama-C (in which `ocamlfind` is required for everything). So your `Makefile.config` is actually normal, and my initial answer was partially wrong. Unfortunately, there is no 100% perfect solution for Aluminium, because it depends on whether `lablgtk` is installed through `ocamlfind`. Your partial fix is probably the way to go. – byako Aug 06 '16 at 12:47