
On Sun, Feb 1, 2009 at 11:57 AM, Antoine Latter
Funny story,
If I do the following three things, I get errors on my Intel Mac OS 10.5:
* Build an executable with Cabal * Have the executable have a build-dep of pcre-light in the .cabal * use haskeline in the executable itself
I get crazy linker errors relating to haskeline and libiconv:
Shell output:
$ cabal clean && cabal configure && cabal build cleaning... Configuring test-0.0.0... Preprocessing executables for test-0.0.0... Building test-0.0.0... [1 of 1] Compiling Main ( test.hs, dist/build/test/test-tmp/Main.o ) Linking dist/build/test/test ... Undefined symbols: "_iconv_open", referenced from: _s9Qa_info in libHShaskeline-0.6.0.1.a(IConv.o) "_iconv_close", referenced from: _iconv_close$non_lazy_ptr in libHShaskeline-0.6.0.1.a(IConv.o) "_iconv", referenced from: _sa0K_info in libHShaskeline-0.6.0.1.a(IConv.o) ld: symbol(s) not found
collect2: ld returned 1 exit status <<<<<
But all three above conditions need to be true - if I build using 'ghc --make' everything works great, even if the executable imports pcre-light and haskeline. If I have build-deps on haskeline and pcre-light, but don't actually import haskeline, everything also works great.
Here are the files I've used:
test.hs:
import System.Console.Haskeline
main :: IO () main = print "Hello!" <<<<<
test.cabal
Name: test version: 0.0.0 cabal-version: >= 1.2 build-type: Simple
Executable test main-is: test.hs build-depends: base, haskeline, pcre-light>=0.3 <<<<<
Is there some way I need to be building haskeline on OS X to make this work?
Thanks, Antoine
more details:
$ cabal --version cabal-install version 0.6.0 using version 1.6.0.1 of the Cabal library <<<<<
$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.0.20081007 <<<<<
links: pcre-light: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pcre-light haskeline: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskeline
For folks following along at home, the above example starts working again if I hard-code some LD flags into my example .cabal file:
Name: test version: 0.0.0 cabal-version: >= 1.2 build-type: Simple
Executable test main-is: test.hs build-depends: base, iconv, pcre-light>=0.3 ld-options: -L/usr/lib -L/opt/local/lib <<<<< This way I make sure that I'm linking against the "good" version of iconv instead of the Mac Ports version. I'm not sure what a general solution is. -Antoine