Confused about readline/editline

Hello café, I'm trying to write an executable that depends on Yogurt-0.3, readline (indirectly) and hint. However, including hint in the build-depends field causes cabal to link the executable against editline instead of readline. Here is a small test case: File: Test.cabal
Name: Test Version: 0
Build-Type: Simple Cabal-Version: >= 1.2
Executable test Main-Is: Test.hs Build-Depends: base, Yogurt, hint GHC-Options: -threaded
File: Test.hs
module Main where
import Network.Yogurt
main:: IO () main = do connect "eclipse.cs.pdx.edu" 7680 (return ())
The example doesn't use any functions from hint, but simply mentioning it in the cabal file causes this behaviour. What's going on? How can I fix or work around this? I am able to reproduce this behaviour in two configurations: * Leopard Intel; cabal-install version 0.6.2, using version 1.6.0.1 of the Cabal library; GHC 6.10.1 * Ubuntu; cabal-install version 0.6.2, using version 1.6.0.3 of the Cabal library; GHC 6.10.2 Thank you very much in advance, Martijn.

On Sun, Apr 5, 2009 at 10:06 AM, Martijn van Steenbergen
Hello café,
I'm trying to write an executable that depends on Yogurt-0.3, readline (indirectly) and hint. However, including hint in the build-depends field causes cabal to link the executable against editline instead of readline. Here is a small test case:
File: Test.cabal
Name: Test Version: 0
Build-Type: Simple Cabal-Version: >= 1.2
Executable test Main-Is: Test.hs Build-Depends: base, Yogurt, hint GHC-Options: -threaded
File: Test.hs
module Main where
import Network.Yogurt
main:: IO () main = do connect "eclipse.cs.pdx.edu" 7680 (return ())
The example doesn't use any functions from hint, but simply mentioning it in the cabal file causes this behaviour. What's going on? How can I fix or work around this?
I am able to reproduce this behaviour in two configurations: * Leopard Intel; cabal-install version 0.6.2, using version 1.6.0.1 of the Cabal library; GHC 6.10.1 * Ubuntu; cabal-install version 0.6.2, using version 1.6.0.3 of the Cabal library; GHC 6.10.2
Probably what's happening is that hint depends on the ghc package, which links to editline in 6.10 since it includes all the code for ghci. I'm not sure, but there might be some order of flags or packages you could give to Cabal which would cause it to link to readline first; I think if gcc gets "-lreadline -ledit" in that order then it will do what you want. Passing "-v" or "-v3" to cabal build should let you see what's going on. For ghc-6.12 there's plans to prevent this issue by separating out ghci as a separate program than the core ghc package. -Judah

Judah Jacobson wrote:
I'm not sure, but there might be some order of flags or packages you could give to Cabal which would cause it to link to readline first; I think if gcc gets "-lreadline -ledit" in that order then it will do what you want. Passing "-v" or "-v3" to cabal build should let you see what's going on.
Yes, -v3 indeed shows that edit comes before readline. Adding this extra line fixes it:
Extra-Libraries: readline
Is adding that extra line a robust, portable and documented way of solving the problem? Whew, I'm really glad it's fixed now. It took me half a day to narrow the problem down. :-) Thanks, Martijn.
participants (2)
-
Judah Jacobson
-
Martijn van Steenbergen