Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Producing a C wrapper with ocamlbuild or OMake
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Joel Reymont <joelr1@g...>
Subject: Re: [Caml-list] Producing a C wrapper with ocamlbuild or OMake

I think I'm missing one more bit:

ocamlbuild main

+ ocamlfind ocamlopt -package ounit -output-obj -o  
No implementations provided for the following modules:
   Symtab referenced from morpher.cmx
   Ninja referenced from morpher.cmx
   Easy_lexer referenced from morpher.cmx
   Easy_parser referenced from morpher.cmx
   Ppninja referenced from morpher.cmx
   Pretty referenced from morpher.cmx
   Parser_util referenced from morpher.cmx
   Ninja_morph referenced from morpher.cmx
Command exited with code 2.
Compilation unsuccessful after building 2 targets (1 cached) in  

My complete plugin file is below. I can build my test program just  
fine using

ocamlbuild test.byte

but trying to produce the library gives me the above error.

What am I missing? How can I have automatically pull in  
the other modules?

I do open modules at the top of like this

open Ninja_morph
open Parser_util
module PP = Ppninja
module N = Ninja

	Thanks, Joel


open Ocamlbuild_plugin;;
open Command;;

let cc = A"cc";;
let ar = A"ar";;
let packages = "ounit" (* "pkg1,pkg2,..." *);;

let ocamlfind cmd =
S[A"ocamlfind"; A cmd; A"-package"; A packages];;

flag ["ocaml"; "link"] (A"-linkpkg");;

dispatch begin function
| After_options ->
      Options.ocamlc := ocamlfind "ocamlc";
      Options.ocamlopt := ocamlfind "ocamlopt";
| After_rules ->
      rule "output C obj"
        begin fun env _ ->
          let caml_o = env "%caml.o" and ml = env "" in
            Cmd(S[!Options.ocamlopt; A"-output-obj"; P ml; A"-o"; Px  
      rule "build C lib"
        ~deps:["%_stubs.o"; "%caml.o"]
        begin fun env _ ->
          let wrap_o = env "%wrap.o"
          and caml_o = env "%caml.o"
          and libasmrun = ! 
          and lib_a = env "lib%.a" in
            Seq[cp libasmrun lib_a;
                Cmd(S[ar; A"r"; Px lib_a; P caml_o; P wrap_o])]
      rule "build morpher"
        ~deps:["libmorpher.a"; "main.o"]
        begin fun _ _ ->
          Cmd(S[cc; P"morpher.o"; P"libmorpher.a"; A"-o"; Px"main"])
| _ -> ()