使用dune包括子包(没有为模块提供实现,但模块在dune文件中)。

huangapple go评论89阅读模式
英文:

Including subpackages using dune (no implementation provided for modules, but modules are in dune file)

问题

在使用 dune 编译一个项目,该项目使用 fmtlogs 包时,我遇到了这个奇怪的错误:

File "_none_", line 1:              
Error: No implementations provided for the following modules:
         Fmt_cli referenced from bin/.main.eobjs/native/dune__exe__Main.cmx
         Logs_fmt referenced from bin/.main.eobjs/native/dune__exe__Main.cmx
         Fmt_tty referenced from bin/.main.eobjs/native/dune__exe__Main.cmx
         Logs_cli referenced from bin/.main.eobjs/native/dune__exe__Main.cmx

这明显表明链接器缺少包含这些模块的目标文件。

问题在于,我已经检查了,这些库已经使用 opam 安装在当前的 switch 中,而且我的 dune 文件包含了以下内容:

 (libraries ... fmt logs))
英文:

While compiling a project with dune that uses the fmt and logs packages , I ended up getting this weird error

File "_none_", line 1:              
Error: No implementations provided for the following modules:
         Fmt_cli referenced from bin/.main.eobjs/native/dune__exe__Main.cmx
         Logs_fmt referenced from bin/.main.eobjs/native/dune__exe__Main.cmx
         Fmt_tty referenced from bin/.main.eobjs/native/dune__exe__Main.cmx
         Logs_cli referenced from bin/.main.eobjs/native/dune__exe__Main.cmx

This clearly indicates that the linker is missing the object file containing those modules.

Problem, I checked, those libraries are installed with opam in the current switch, and my dune file contains

 (libraries ... fmt logs))

答案1

得分: 2

在搜索了一下之后,我意识到这些模块包含在opam开关中的单独对象文件中

_opam/lib/fmt/fmt_cli.cmx
_opam/lib/fmt/fmt_tty.cmx
_opam/lib/logs/logs_fmt.cmx
_opam/lib/logs/logs_cli.cmx

这些都是opam的子包(每个都在同一目录下的META文件中定义)

我需要将它们分别添加到依赖项中,如下所示

 (libraries ... fmt logs fmt.cli fmt.tty logs.fmt logs.cli))

英文:

After searching a bit, I realized those modules are contained in separate object files in the opam switch

_opam/lib/fmt/fmt_cli.cmx
_opam/lib/fmt/fmt_tty.cmx
_opam/lib/logs/logs_fmt.cmx
_opam/lib/logs/logs_cli.cmx

Those are part of opam subpackages (each defined in the META file in the same directory)

I needed to add them individually to the dependencies with the following

 (libraries ... fmt logs fmt.cli fmt.tty logs.fmt logs.cli))

huangapple
  • 本文由 发表于 2023年7月18日 05:56:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708323.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定