Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GHC Linker error (stack)

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?

like image 322
DeX3 Avatar asked Oct 22 '15 11:10

DeX3


1 Answers

As yuras correctly pointed out, adding the module under exposed-modules in the cabal file resolves the issue.

like image 172
DeX3 Avatar answered Oct 26 '22 23:10

DeX3