[英]GHC Linker error (stack)
I'm somewhat of a beginner in Haskell and I'm trying out stack to build an application. 我在Haskell中有点初学者,我正在尝试使用堆栈来构建应用程序。
However, stack build
gives me linker errors when executed: 但是, stack build
在执行时会给出链接器错误:
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/sim-exe/sim-exe ...
[...]/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/libHSsim-0.1.0.0-EmdGqYS9bXF9VefempSPEG.a(Lib.o):(.text+0x98f5): undefined reference to `simzuEmdGqYS9bXF9VefempSPEG_Linter_lint_info'
[...]/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/libHSsim-0.1.0.0-EmdGqYS9bXF9VefempSPEG.a(Lib.o):(.data+0x5f0): undefined reference to `simzuEmdGqYS9bXF9VefempSPEG_Linter_lint_closure'
collect2: error: ld returned 1 exit status
Looking at the labels tells me it's related to a closure in this function: 查看标签告诉我它与此函数中的闭包有关:
lint :: String -> [LintError]
lint source = let
handleParseError :: ParseError -> [LintError]
handleParseError e = [LintError (fromSourcePos $ errorPos e) $ format e]
in
case parseSim source of
(Left error) -> handleParseError error
(Right prog) -> lintProgram prog
But there's not really a closure in there? 但那里真的没有关闭? If I replace the implementation of lint
with 如果我用lint
替换lint
的实现
lint _ = []
it compiles fine. 它编译得很好。
I can execute stack ghci
and play around with the full lint
implementation just fine. 我可以执行stack ghci
并使用完整的lint
实现就好了。 Why does it fail to link? 为什么它无法链接?
正如yuras正确指出的那样,在cabal文件中的exposed-modules
下添加模块可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.