I'm somewhat of a beginner in Haskell and I'm trying out stack to build an application.
However, stack build
gives me linker errors when executed:
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 _ = []
it compiles fine.
I can execute stack ghci
and play around with the full lint
implementation just fine. Why does it fail to link?
正如yuras正确指出的那样,在cabal文件中的exposed-modules
下添加模块可以解决问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.