Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlbuild: -use-runtime flag not working?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hugo Ferreira <hmf@i...>
Subject: ocamlbuild: -use-runtime flag not working?
Hello,

I am attempting to use the MLCuDD library that gives me access to
the CuDD C library. I order to use this library I did various
successful experiments using the ocamlbuid command-line.
Two examples are:

  # Bytecode, one option
ocamlbuild -no-hygiene -Is $PROJ_PATH -lib cudd -cflags 
-I,/home/hugof/Desktop/cudd/ -lflags 
-I,/home/hugof/Desktop/cudd/,-use-runtime,/home/hugof/Desktop/cudd/cuddrun 
-verbose 100 src/parser.byte

Bytecode, second option
#ocamlbuild -no-hygiene -Is $PROJ_PATH -lib cudd -cflags 
-I,/home/hugof/Desktop/cudd/ -lflags 
-I,/home/hugof/Desktop/cudd/,-custom -verbose 100 src/parser.byte

I assume that the use of "-custom" and "-use-runtime" are equivalent.
I then proceeded to use the _tags and myocamlbuild.ml files.
The contents of these are:

cat _tags
true: use_menhir, debug, profile
<cudd/**>: not_hygienic
"src/parser.d.byte": use_unix, use_cudd

cat myocamlbuild.ml
open Ocamlbuild_plugin;;
open Command;;

dispatch begin function
| After_rules ->
     (* add CuDD library as external library *)
     ocaml_lib ~extern:true ~dir:"/home/hugof/Desktop/cudd" "cudd";

     (* CuDD is a C library. So handle native code linking correctly *)
     flag ["link"; "ocaml"; "byte" ; "use_cudd"]
     (*(S[A"-custom"]);*)
     (S[A"-use-runtime"; A"/home/hugof/Desktop/cudd/cuddrun"]);

| _ -> ()
end;;

Unfortunately, using the above files with the following command:

PROJ_PATH="cudd,src"
ocamlbuild -Is $PROJ_PATH -verbose 100 all.otarget

fails with:

+ /home/hugof/ocaml/godi/bin/ocamlc.opt unix.cma -g -I 
/home/hugof/Desktop/cudd cudd.cma -use-runtime 
/home/hugof/Desktop/cudd/cuddrun src/parser.d.cmo -o src/parser.d.byte
Error while linking /home/hugof/ocaml/godi/lib/ocaml/std-lib/unix.cma(Unix):
The external function `unix_dup' is not available
Command exited with code 2.

However if I use (S[A"-custom"]); compilation succeeds.
Am I doing anything wrong?

TIA,
Hugo Ferreira.