7
votes

My question comes in two parts. The first is that when I compile my project I get a long list of errors of the form

  (.text+0x137f): undefined reference to `raytrzuAd6RComi0WmBiuT4685WWH_Types_zdfBinaryColor_closure'

The full list of errors can be found here The code that produces this error can be found here.

I am using ghc 7.10.1 and cabal 1.22.4.0.

The second part of my question is that despite following the same cabal structure as this question, cabal still recompiles the library 3 times each cabal build despite the executables and the library all having a unique hs-source-dir and depending on the library.

EDIT: as far as the triple compilation is concerned, the first time it builds .o files [ 2 of 15] Compiling Types ( src/Types.hs, dist/build/Types.o ). The second time it builds .p_o files [ 2 of 15] Compiling Types ( src/Types.hs, dist/build/Types.p_o ) which are caused by TemplateHaskell and profiling.

1
You should include all the other non-exported modules in your Cabal file in the other-modules field – does that fix your linking problem? (I can't test myself as I'm still on 7.8.3, so I can't build your code.) - Antal Spector-Zabusky
It looks like that fixes the undefined reference problem works <3 <3 <3. - Justin Raymond
@AntalSpector-Zabusky as this resolved the problem, you should post it as an answer :-) - sclv
@sclv: Good point :-) - Antal Spector-Zabusky

1 Answers

6
votes

You should include all the other non-exported modules in your Cabal file in the other-modules field, otherwise they won't be linked in properly when producing the final library or executable.

You can see the Cabal User's Guide for more information (although that pretty much sums up the situation with other-modules!).