2016-12-04 53 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应该解决问题。