正确编译子文件夹中的模块(ocamlbuild)

发布于 2024-08-20 14:18:07 字数 1440 浏览 4 评论 0原文

我最近决定整理我的项目目录中的文件。我将几种不同文件类型的解析器移至它们自己的目录中,并决定使用 ocamlbuild(因为项目变得越来越复杂,简单的 shell 脚本不再足够)。

我能够通过使用一些基本规则修改 myocamlbuild 来成功包含外部项目(调用 ocaml_lib,我将在其他时间使用 ocamlfind),但我坚持如何将文件夹作为模块包含到项目正常进行。我创建了一个 parser.mlpack 文件,并用要包含的正确模块填充了它(例如“parser/Date”等),在其中编写了一个 parser.mli其实现的目录的根目录,并修改了 _tags 文件(见下文)。

编译过程中正确遍历了parser目录,在_build目录下创建了parser.cmiparser.mli.depends;以及解析器子目录中的所有 *.cm[xio] 文件。

我觉得我可能做了一些多余的事情,但无论如何,当我编译时,项目仍然找不到解析器模块!

谢谢!

_tags

debug : true
<*.ml> : annot
"parser" : include
<parser/*.cmx>: for-pack(Parser)
<curlIO.*> : use_curl
<mySQL.*> : use_mysql
<**/*.native> or <**/*.byte> : use_str,use_unix,use_curl,use_mysql

编译错误

/usr/local/bin/ocamlopt.opt unix.cmxa str.cmxa -g -I /usr/local/lib/ocaml/site-lib/mysql mysql.cmxa -I /usr/local/lib/ocaml/curl curl.cmxa curlIO.cmx utilities.cmx date.cmx fraction.cmx logger.cmx mySQL.cmx data.cmx project.cmx -o project.native  
File "\_none\_", line 1, characters 0-1:  
Error: **No implementations provided for the following modules:**
         Parser referenced from project.cmx  
Command exited with code 2.  

你会注意到-I parser没有包含在上面的链接阶段;实际上没有包含任何与解析器相关的文件!

编辑:从下面的评论和答案中添加了新的详细信息。

I recently decided to organize the files in my project directory. I moved the parsers I had for a few different file types into their own directory and also decided to use ocamlbuild (the as the project was getting more complicated and the simple shell script was not sufficient any longer).

I was able to successfully include external projects by modifying myocamlbuild with some basic rules (calling ocaml_lib, I'll use ocamlfind some other time), but I am stuck on how to include the folder as a module into the project properly. I created a parser.mlpack file and filled it with the proper modules to be included (eg, "parser/Date", et cetera), wrote a parser.mli in the root of the directory for their implementations, and modified the _tags file (see below).

During the compilation, the parser directory is traversed properly, and parser.cmi, parser.mli.depends were both created in the _build directory; as well as all *.cm[xio] files in the parsers subdirectory.

I feel I might be doing something redundant, but regardless, the project still cannot find the Parser module when I compile!

Thanks!

_tags

debug : true
<*.ml> : annot
"parser" : include
<parser/*.cmx>: for-pack(Parser)
<curlIO.*> : use_curl
<mySQL.*> : use_mysql
<**/*.native> or <**/*.byte> : use_str,use_unix,use_curl,use_mysql

compilation error

/usr/local/bin/ocamlopt.opt unix.cmxa str.cmxa -g -I /usr/local/lib/ocaml/site-lib/mysql mysql.cmxa -I /usr/local/lib/ocaml/curl curl.cmxa curlIO.cmx utilities.cmx date.cmx fraction.cmx logger.cmx mySQL.cmx data.cmx project.cmx -o project.native  
File "\_none\_", line 1, characters 0-1:  
Error: **No implementations provided for the following modules:**
         Parser referenced from project.cmx  
Command exited with code 2.  

You'll notice -I parser is not included in the linking phase above; actually none of the parser related files are included!

edit: Added new details from comments and answer below.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

污味仙女 2024-08-27 14:18:07

您需要在搜索路径中“包含”解析器目录。您可以在 _tags 中执行此操作:

"parser": include

然后 ocamlbuild 可以在解析器目录中搜索感兴趣的文件。

You need to "include" the parser directory in the search path. You can do this in _tags:

"parser": include

Then ocamlbuild can search the parser directory for interesting files.

哑剧 2024-08-27 14:18:07

我想知道 parser.mli 是否以某种方式干扰了处理 mlpack 文件的依赖关系。当处理和编译parser.mlpack时,将通过pack操作生成parser.cmi。尝试在删除 parser.mli 文件的情况下进行构建。如果有效,那么可以将其重新处理为真正的答案。

此外,如果 parser.mlpack 位于 中,则不需要将 parser/ 作为 parser.mlpack 中模块的前缀parser 目录,并且您已设置 include 标记。但这应该不会有什么不同。

更新:这解决了问题,但不是根本原因。根据下面的评论,根本原因是 .mlpack 中提到的一个文件已被重新定位。

I wonder if parser.mli is somehow interfering with the dependencies in processing the mlpack file. parser.cmi will be generated from the pack operation when parser.mlpack is processed and compiled. Try building with the parser.mli file removed. If that works, then this can be re-processed into a real answer.

Also, you don't need parser/ as a prefix to your modules in parser.mlpack if parser.mlpack is in the parser directory and you have the include tag set. But that shouldn't make a difference for this.

Update: this worked around the problem, but wasn't the root cause. Root cause, per comment below, was a file mentioned in the .mlpack that had been relocated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文