Makefile 未绑定模块Yojson.Basic.Util

Makefile 未绑定模块Yojson.Basic.Util,makefile,build,functional-programming,ocaml,Makefile,Build,Functional Programming,Ocaml,我尝试在我的一个文件中打开Yojson.Basic.Util,并不断得到一个unbound模块错误。我试过几种不同的方法,但似乎都不知道怎么回事 我的.ocamlinit中有这个: #require "yojson";; #require "ANSITerminal";; 在我的makefile中: test: ocamlbuild -pkg yojson, oUnit test.byte && ./test.byte play: ocamlbuild -pk

我尝试在我的一个文件中打开
Yojson.Basic.Util
,并不断得到一个u
nbound模块
错误。我试过几种不同的方法,但似乎都不知道怎么回事

我的
.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
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
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 -pkg yojson, oUnit test.byte && ./test.byte
ocamlfind: Package `yojson,' not found
Cannot run Ocamlfind.
make: *** [test] Error 2
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

ocamlbuild的
-pkg
-pkgs
选项之间存在差异。
-pkg
选项只使用一个包名。
-pkgs
选项采用逗号分隔的包名列表(逗号前后可以有可选空格,但必须引用参数)

在您的示例中,您使用了
-pkg
,但是使用了逗号分隔的参数列表,并且该列表有一个空格,因此必须引用它。使用
-pkgs-yojson,oUnit
应该可以解决这个问题