[Haskell-beginners] Cabal dependencies are per target or global?

Dimitri DeFigueiredo defigueiredo at ucdavis.edu
Fri Jul 17 23:08:13 UTC 2015


I guess my example was incomplete. I can make GHC run. Here's a modified 
version where I do have the ghc-options line. I can build an executable 
for the second target (myPersonalMain) by commenting
the "build-depends: section" for the first target (agent).
My .cabal file with (commented lines) is:
------------------------------------------------
name:                agent
version:             0.1.0.0
build-type:          Simple
cabal-version:       >=1.20
------------------------------------------------
executable agent
   main-is:             Main.hs
   hs-source-dirs: ./src

   -- build-depends:      base >=4.6 && <4.7
   --                   , unordered-containers >= 0.2.3.0
   --                   , unix >= 2.6.0.1
   --                   , process >= 1.1.0.2
   --                   , stm >= 2.4.2

   -- Base language which the package is written in.
   default-language:    Haskell2010

----------------------------------------------
executable myPersonalMain
     main-is:            Mpm.hs
     hs-source-dirs:     ./src
     ghc-options:       -main-is Mpm
     build-depends:
                 base              >=4.4

     default-language:   Haskell2010
----------------------------------------------

The contents of Mpm.hs are:

module Mpm where
main = putStrLn "Hi!"

But if I remove the comments in the .cabal file above, I get this:

Dis-machine:cabal-tests dimitri$ cabal build myPersonalMain
./agent.cabal has been changed. Re-configuring with most recently used
options. If this fails, please run configure manually.
Resolving dependencies...
Configuring agent-0.1.0.0...
cabal: At least the following dependencies are missing:
process >=1.1.0.2,
stm >=2.4.2,
unix >=2.6.0.1,
unordered-containers >=0.2.3.0



Is this a bug? Or am I missing something?


Cheers,


Dimitri




On 17/07/15 15:10, Imants Cekusins wrote:
> this could shed some light:
>
> http://stackoverflow.com/questions/14238729/producing-multiple-executables-from-single-project
>
> answer #2 was marked as answered
>
> ghc-options:      -O2 -threaded -with-rtsopts=-N -main-is FirstExecutable



More information about the Beginners mailing list