GHC 未定义对依赖路径的引用

GHC undefined reference to Paths in dependency

最近做了一个cabal包可以看到here 它由一个库和一些使用它的小示例程序组成。一切都按预期构建和工作。

我想在一个使用这个库的新包中构建一个可执行文件,但是我继续 运行 进入一个我无法破译的链接错误:

/my/path/RandomAgent/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/rlglue-0.2.1.1/libHSrlglue-0.2.1.1.a(Agent.o):(.text+0x34f1): undefined reference to `rlgluezm0zi2zi1zi1_Pathszurlglue_version1_closure'

collect2:错误:ld 返回 1 退出状态 为了使诊断更简单,我将其中一个示例程序移到了我的新包中,但发现它甚至无法正确构建。您可以找到该版本的可执行文件 here.

据此我得出结论,问题可能出在我在 .cabal 文件中所做的事情中,但我看不出哪里出了问题。该错误似乎还涉及 cabal 为第一个包自动生成的 Paths_rlglue 模块。

谁能帮我理解为什么会出现这个错误?

看来我在 Paths_pkgname

的文档中遗漏了一些内容

If you decide to import the Paths_pkgname module then it must be listed in the other-modules field just like any other module in your package.

将 Paths_rlglue 添加到我的图书馆的其他模块解决了这个问题。希望这可以挽救我在这方面迷失的所有时间。

您需要像项目中的任何其他模块一样将 Paths_rlglue 模块包含在 exposed-modules 或 other-modules 中,以便 Cabal link 它。

Cabal 应该更好地告诉您发生了什么,请参阅 https://github.com/haskell/cabal/issues/1746