ghc 编译错误“输出已使用 -o 重定向,但不会生成任何输出,因为没有主模块。”

问题描述 投票:0回答:1

当谷歌搜索此错误时没有看到任何相关结果,所以我想发布它。

stack build
Building all executables for `gitchapter' once. After a successful build of all of them, only specified executables will be rebuilt.
gitchapter-0.1.0.0: build (exe)
Preprocessing executable 'app' for gitchapter-0.1.0.0..
Building executable 'app' for gitchapter-0.1.0.0..
Preprocessing executable 'test' for gitchapter-0.1.0.0..
Warning: Enabling workaround for Main module 'Main' listed in 'other-modules'
Building executable 'test' for gitchapter-0.1.0.0..
illegaly!

<no location info>: error:
    output was redirected with -o, but no output will be generated
because there is no Main module.


--  While building custom Setup.hs for package gitchapter-0.1.0.0 using:
      /home/chris/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-2.0.1.0 build exe:app exe:test --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

它肯定与“测试”可执行文件定义有关 - 就好像我删除它一样,它成功完成了

stack build
- 但没有所需的测试可执行文件。

gitchapter.cabal

-- This file has been generated from package.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: a3e4a735ee8304dd50f5af53a64d7b639894cbcc24ba01d0171a588e67455018

name:           gitchapter
version:        0.1.0.0
author:         Chris Stryczynski
maintainer:     Chris Stryczynski
license:        BSD3
license-file:   LICENSE
build-type:     Simple
cabal-version:  >= 1.10

executable app
  main-is: Main.hs
  other-modules:
      BlogLiterately
      Example
      FileSection
      GHCi
      GHCiSession
      Git
      GitTextPartial
      Hart
      Operations
      Operations.Parsers
      QuasiText
      Render
      Section
      Test
      Paths_gitchapter
  hs-source-dirs:
      src
  build-depends:
      HUnit
    , QuickCheck
    , base >=4.9 && <4.11
    , directory
    , extra
    , filepath
    , foldl
    , mtl
    , optparse-applicative
    , pandoc-include-code
    , parsec
    , pretty-simple
    , process
    , regex-pcre
    , regex-posix
    , safe
    , string-conversions
    , system-filepath
    , template-haskell
    , text
    , transformers
    , turtle
    , unix
    , unordered-containers
  default-language: Haskell2010

executable test
  main-is: Test.hs
  other-modules:
      BlogLiterately
      Example
      FileSection
      GHCi
      GHCiSession
      Git
      GitTextPartial
      Hart
      Main
      Operations
      Operations.Parsers
      QuasiText
      Render
      Section
      Paths_gitchapter
  hs-source-dirs:
      src
  build-depends:
      HUnit
    , QuickCheck
    , base >=4.9 && <4.11
    , directory
    , extra
    , filepath
    , foldl
    , mtl
    , optparse-applicative
    , pandoc-include-code
    , parsec
    , pretty-simple
    , process
    , regex-pcre
    , regex-posix
    , safe
    , string-conversions
    , system-filepath
    , template-haskell
    , text
    , transformers
    , turtle
    , unix
    , unordered-containers
  default-language: Haskell2010
haskell cabal haskell-stack
1个回答
7
投票

您需要设置

executable test
  ghc-options:  -main-is Test

在你的阴谋集团文件中。

© www.soinside.com 2019 - 2024. All rights reserved.