我正在尝试使用ocamlfind来安装图书馆。我正在使用OCamlMakeFile。这是我的Makefile:
OCAMLMAKEFILE = OCamlMakeFile
RESULT = owebl
SOURCES = src/utils.ml src/verb.ml src/request.ml src/template.ml src/response.ml src/rule.ml src/handler.ml src/server.ml
PACKS = unix str
all: native-code-library byte-code-library
install: libinstall
uninstall: libuninstall
include $(OCAMLMAKEFILE)基本上,这个库是一个我想要分发的模块的集合。库的一个基本用法是(main.ml):
open Response
open Rule
open Verb
open Server
let handler =
Handler.create
(StaticRouteRule.create "/" [GET])
(FileResponse.create
~static_file:(FileResponse.StaticFile "/index.html")
())
let server = Server.create "0.0.0.0" 8080 [handler];;
server#serve我只是通过运行"make“来编译这个库。它生成三个文件:"owebl.a,owebl.cma,owebl.cmxa“。然后使用ocamlfind安装库:
ocamlfind install owebl META owebl.a owebl.cma owebl.cmxa噢,元文件是:
version = "0.1"
name = "OWebl"
description = "A Web Framework for OCaml"
archive(byte) = "owebl.cma"
archive(native) = "owebl.cmxa"
requires = "unix,str"在我试图编译上面使用库的示例之前,一切都是正常的。我跑:
ocamlbuild -use-ocamlfind -pkgs owebl main.native我得到了:
ocamlbuild -use-ocamlfind -pkgs owebl main.native
+ ocamlfind ocamlc -c -package owebl -o main.cmo main.ml
File "main.ml", line 1, characters 5-10:
Error: Unbound module Owebl
Command exited with code 2.
Hint: Recursive traversal of subdirectories was not enabled for this build,
as the working directory does not look like an ocamlbuild project (no
'_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
you should add the option "-r" or create an empty '_tags' file.
To enable recursive traversal for some subdirectories only, you can use the
following '_tags' file:
true: -traverse
<dir1> or <dir2>: traverse
Compilation unsuccessful after building 2 targets (1 cached) in 00:00:00.
make: *** [fileserver] Error 10我试着将open Owebl添加到main.ml的开头,但我也得到了类似的“”。我非常不明白为什么这些模块都是不绑定的。我遗漏了什么?
发布于 2015-03-21 03:59:40
如果您想要将模块打包到伞式命名空间(如LIB_PACK_NAME )下,如OWebl,则应该使用Response变量,否则它们将按原样可用,例如Response、Rule等。此外,您还应该在SOURCES变量中指定mli文件和ml文件。最后,您不应该忘记安装cmi文件以及.a文件。安装mli文件也被认为是一个很好的传统,尽管并不是严格要求的。另外,考虑使用OCamlMakefile安装工具而不是自定义安装脚本。
发布于 2015-03-21 01:36:34
因此,我不再使用OCamlMakefile,因此不确定,但假设OCamlMakefile使用-for-pack OWebl选项编译东西,并正确构建打包的模块owebl.cmo,则还需要安装owebl.cmi。
OCaml编译器查找cmi文件来检查模块的存在并获取它们的类型信息。如果未安装,编译器将无法找到它。cma和cmxa文件是对象的集合,不提供类型信息。
https://stackoverflow.com/questions/29178010
复制相似问题