英文:
Including subpackages using dune (no implementation provided for modules, but modules are in dune file)
问题
在使用 dune
编译一个项目,该项目使用 fmt 和 logs 包时,我遇到了这个奇怪的错误:
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))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论