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?
As yuras correctly pointed out, adding the module under exposed-modules
in the cabal file resolves the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With