简体   繁体   中英

(Ocaml) Error: Unbound module Ocamlbuild_pack.Ocamlbuild_Myocamlbuild_config

i am trying to compile a ocaml program (part of it shown below)

open Ocamlbuild_plugin
open Command

(** helper functions )
( splitting strings using a delimeter character *)
let rec strsplit sep str accu len =
try let idx = String.rindex_from str (len - 1) sep in
strsplit sep str ((String.sub str (idx + 1) (len - 1 - idx)) :: accu) idx
with Not_found -> (String.sub str 0 len) :: accu
let strsplit sep str = strsplit sep str [] (String.length str)

(** initializing variables from the environment *)
let host = Ocamlbuild_pack.Ocamlbuild_Myocamlbuild_config.system

the last line is causing unbound module error. What can i do? thanks

update 1:

The code is from a github project https://github.com/ykazakov/cb-reasoner

And i am following an instruction there to use "make" to compile the program .. this make file looks like this

BUILDDIR ?= _build
OCAMLBUILD ?= ocamlbuild
OCAMLBUILD := $(OCAMLBUILD) -build-dir $(BUILDDIR)

.PHONY: main clean clib

main:
    $(OCAMLBUILD) main/cb.native

all:
    $(OCAMLBUILD) main/cb.native jni cwrap/libcb.a

cwrap:  
    $(OCAMLBUILD) cwrap/libcb.a

jni:
    $(OCAMLBUILD) jni

clean: 
    $(OCAMLBUILD) -clean;\
    rm -f cb.native

I answered this question on the ocamlbuild issue tracker (I follow StackOverflow but less closely, sorry). Quoting below for convenience:

OCamlbuild exports a stable interface for plugin users as the Ocamlbuild_plugin module. Using Ocamlbuild_pack directly accesses ocamlbuild's internal definitions, and is recommended against as there are no guarantees of backward-compatibility.

In your specific case, a module is used by this code that indeed was removed in more recent ocamlbuild versions (its presence was an artifact of the specific way ocamlbuild's build system was integrated into the compiler distribution). I could correctly build this software with OCaml 3.12.1, 4.00.1 and 4.01.0, but not any more recent version of OCaml and ocamlbuild.

Using opam makes it easy to install old OCaml versions:

 opam install 4.01.0 eval $(opam env --switch=4.01.0) make # if in the project's directoyr 

If you are interested in patching this software to make it compatible with more recent OCaml versions, we could discuss how to get the corresponding information in a more robust way.

In any case, I'm closing this as it is not a problem of ocamlbuild, but rather a maintenance question for cb-reasoner. (Of course, feel free to post further comments.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM