【发布时间】:2014-02-25 23:04:11
【问题描述】:
我已阅读this question 和其他人, 但是我的编译问题没有解决。
我正在使用这些文件测试单独的编译:
testmoda.ml
module Testmoda = struct
let greeter () = print_endline "greetings from module a"
end
testmodb.ml
module Testmodb = struct
let dogreet () = print_endline "Modul B:"; Testmoda.greeter ()
end
testmod.ml
let main () =
print_endline "Calling modules now...";
Testmoda.greeter ();
Testmodb.dogreet ();
print_endline "End."
;;
let _ = main ()
现在我生成 .mli 文件
ocamlc -c -i testmoda.ml >testmoda.mli
testmoda.cmi 就在那里。
接下来我创建没有错误的 .cmo 文件:
ocamlc -c testmoda.ml
很好,对 testmodb.ml 做同样的事情:
strobel@s131-amd:~/Ocaml/ml/testmod> ocamlc -c -i testmodb.ml >testmodb.mli
File "testmodb.ml", line 3, characters 45-61:
Error: Unbound value Testmoda.greeter
再试一次:
strobel@s131-amd:~/Ocaml/ml/testmod> ocamlc -c testmoda.cmo testmodb.ml
File "testmodb.ml", line 3, characters 45-61:
Error: Unbound value Testmoda.greeter
其他组合也失败了。
如何编译 testmodb.ml 和 testmod.ml?这应该很容易 - 没有 ocamlbuild / omake / 绿洲,我想。
文件中的语法错误被排除, 如果我将它们放在一个文件中(之间有所需的空间),它会编译 并完美执行。
【问题讨论】:
标签: ocaml