22

次のプロジェクト構造で:

src/FirstExecutable.hs
src/SecondExecutable.hs
my-amazing-project.cabal

および次のカバールの設定:

name:               my-amazing-project
version:            0.1.0.0
build-type:         Simple
cabal-version:      >=1.8

executable first-executable
  hs-source-dirs:   src
  main-is:          FirstExecutable.hs
  ghc-options:      -O2 -threaded -with-rtsopts=-N
  build-depends:    base == 4.5.*

executable second-executable
  hs-source-dirs:   src
  main-is:          SecondExecutable.hs
  ghc-options:      -O2 -threaded -with-rtsopts=-N
  build-depends:    base == 4.5.*

次の出力で実行cabal installが失敗します。

Installing executable(s) in
/Users/mojojojo/Library/Haskell/ghc-7.4.2/lib/my-amazing-project-0.1.0.0/bin
cabal: dist/build/second-executable/second-executable: does not exist
Failed to install my-amazing-project-0.1.0.0
cabal: Error: some packages failed to install:
my-amazing-project-0.1.0.0 failed during the final install step. The exception
was:
ExitFailure 1

私は何を間違っているのですか、それともこれはカバルのバグですか?


実行可能モジュールの内容は次のとおりです。

module FirstExecutable where

main = putStrLn "Running FirstExecutable"

module SecondExecutable where

main = putStrLn "Running SecondExecutable"
4

1 に答える 1

28

cabalは、実行可能ファイルのモジュールがであると想定していますMain。モジュール行をスキップするか、を使用する必要がありますmodule Main where

考えられる理由はここにあります。Mainモジュールが実際にプログラムをコンパイルするときではない場合、haskellプログラムの実行可能ファイルは生成されません。モジュールのmain機能はMain、実行可能ファイルの実行時に使用されます。ghcの可能な回避策は-main-isフラグです。だからあなたは次のようなものを持つことができます

name:               my-amazing-project
version:            0.1.0.0
build-type:         Simple
cabal-version:      >=1.8

executable first-executable
  hs-source-dirs:   src
  main-is:          FirstExecutable.hs
  ghc-options:      -O2 -threaded -with-rtsopts=-N -main-is FirstExecutable
  build-depends:    base == 4.5.*

executable second-executable
  hs-source-dirs:   src
  main-is:          SecondExecutable.hs
  ghc-options:      -O2 -threaded -with-rtsopts=-N -main-is SecondExecutable
  build-depends:    base == 4.5.*
于 2013-01-09T16:00:46.807 に答える