
On Sat, May 3, 2014 at 10:32 PM, Omari Norman
What I figured out is that cabal and/or ghci need to have the C object files listed so that the earlier object files provide the symbols that are needed by the later object files. This is the opposite order one would expect with a linker, where it is generally best to list object files with undefined symbols first, and then list the libraries that provide those objects later.
This sort of cycle fixes the problem:
1. Get error message 2. Use grep and nm to rummage around in dist/build/**/*.o to see what object file provides the missing symbol 3. Rearrange your c-sources to put the needed file earlier 4. Repeat
The library I'm using has no circular dependencies, so I got it working this way. No -fPIC is needed.
My mistake - in addition, you do need to have the cc-options: -fPIC in the .cabal file. Bug here: http://ghc.haskell.org/trac/ghc/ticket/9074