[Haskell-cafe] Using a library in a executable within same cabal package

Arnaud Bailly arnaud.oqube at gmail.com
Sat Apr 24 13:26:02 EDT 2010

You are right, I hit "reply" without checking the destination. Thanks
for your answer.


On Sat, Apr 24, 2010 at 3:24 PM, Ivan Lazar Miljenovic
<ivan.miljenovic at gmail.com> wrote:
> First of all, did you mean to reply back to -cafe as well?
> Arnaud Bailly <arnaud.oqube at gmail.com> writes:
>> I was not precise enough: Yes, I found the examples to have both a
>> library and an executable clear enough that I managed to have
>> something workable. But I found somewhat surprisingly that the modules
>> used in both the library and the executable were compiled twice. I was
>> expecting the executable to link to the dynamic library produced.
>> I understand from your answer this is a known issue.
> Right; with Cabal 1.8 this situation is "solved", but at the expense of
> not being able to build documentation (I think I was the first person to
> fully try this, which is why the bug went unnoticed until recently; the
> darcs people are considering using it as well but they didn't test
> building haddock docs).
> So yeah, at the moment you're stuck with building the library multiple
> times :s
>> On Sat, Apr 24, 2010 at 12:14 PM, Ivan Lazar Miljenovic
>> <ivan.miljenovic at gmail.com> wrote:
>>> Arnaud Bailly <abailly at oqube.com> writes:
>>>> Not sure this question is totally on-topic.
>>> Sure is.
>>>> Please point me in the right direction if it is not. I would like to
>>>> make a cabal package containing both an executable and several
>>>> libraries,
>>> Each cabal package can contain only one library (which is why gtk2hs is
>>> only now starting to be cabalised).
>>>> and link the main executable to the libraries produced in
>>>> the build. It is not clear how I can achieve that from the
>>>> documentation. I tried Extra-libraries option but it does not work.
>>> By default, you don't need to do anything extra to have executables
>>> using a library in the same package (assuming they have the same source
>>> directory) as GHC will find all the modules it needs.
>>> Cabal-1.8 has a new feature that lets executables explicitly depend upon
>>> the libraries, which means the library doesn't need to get rebuilt
>>> several times.  However, this is causing problems with building haddock
>>> documentation: http://hackage.haskell.org/trac/hackage/ticket/656
>>> --
>>> Ivan Lazar Miljenovic
>>> Ivan.Miljenovic at gmail.com
>>> IvanMiljenovic.wordpress.com
> --
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> IvanMiljenovic.wordpress.com

More information about the Haskell-Cafe mailing list