2016-12-04 56 views
1

我嘗試在我的一個文件中打開Yojson.Basic.Util,並且一直收到錯誤信息nbound module。我已經嘗試了幾種不同的事情,似乎無法找出什麼是錯的未綁定的模塊Yojson.Basic.Util

我有這個在我的.ocamlinit

#require "yojson";; 
#require "ANSITerminal";; 

,這在我的makefile

test: 
    ocamlbuild -pkg yojson, oUnit test.byte && ./test.byte 

play: 
    ocamlbuild -pkgs oUnit,yojson,str,ANSITerminal main.byte && ./main.byte 

check: 
    bash checkenv.sh 

clean: 
    ocamlbuild -clean 

打字make產生此錯誤:

ocamlbuild -pkg yojson, oUnit test.byte && ./test.byte 
ocamlfind: Package `yojson,' not found 
Cannot run Ocamlfind. 
make: *** [test] Error 2 

Chan詹姆士的makefile到:

test: 
    ocamlbuild -use-ocamlfind -pkg yojson, oUnit test.byte && ./test.byte 

play: 
    ocamlbuild -pkgs oUnit,yojson,str,ANSITerminal main.byte && ./main.byte 

check: 
    bash checkenv.sh 

clean: 
    ocamlbuild -clean 

我輸入make,這讓我這個錯誤:

ocamlbuild -use-ocamlfind -pkg yojson, oUnit test.byte && ./test.byte 
Solver failed: 
    Ocamlbuild knows of no rules that apply to a target named oUnit. This can happen if you ask Ocamlbuild to build a target with the wrong extension (e.g. .opt instead of .native) or if the source files live in directories that have not been specified as include directories. 
Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00. 
make: *** [test] Error 6 

回答

2

沒有爲ocamlbuild的-pkg-pkgs選項之間的差異。 -pkg選項只需要一個包名稱。 -pkgs選項採用逗號分隔的包名稱列表(在逗號前後可以有可選空格,但必須引用該參數)。

在您的示例中,您使用-pkg,但使用逗號分隔的參數列表,並且該列表具有空格,因此必須引用該列表。使用-pkgs yojson,oUnit應該解決問題。