【问题标题】:ghc can't find the module it's trying to buildghc 找不到它正在尝试构建的模块
【发布时间】:2017-11-16 02:21:28
【问题描述】:

我在 Arch、ghc 8.2.1 和 cabal 2.0 上有最新的包,正在尝试使用 cabal 构建 ncurses 包:

$ cabal configure
Resolving dependencies...
Configuring ncurses-0.2.16...
$ cabal build
Preprocessing library for ncurses-0.2.16..
Building library for ncurses-0.2.16..

<no location info>: error:
    module ‘UI.NCurses’ cannot be found locally

上述模块是我正在尝试构建的包的一部分,它的源文件位于 lib 目录中。 cabal文件里好像都指定了,为什么找不到呢?

我尝试使用 runhaskell 构建它,但得到了同样的错误。

阴谋集团文件的一部分:

extra-source-files:
  cbits/hsncurses-shim.c
  cbits/hsncurses-shim.h
  cbits/mavericks-c2hs-workaround.h

source-repository head
  type: git
  location: https://john-millikin.com/code/haskell-ncurses/

source-repository this
  type: git
  location: https://john-millikin.com/code/haskell-ncurses/
  tag: haskell-ncurses_0.2.16

-- Do not use default to using pkg-config to find ncurses libraries, because
-- the .pc files are missing or broken in many installations.
flag use-pkgconfig
  default: False
  manual: True
  description:
    Use pkg-config to set linker and include flags.

flag force-narrow-library
  default: False
  manual: True
  description:
    Force including and linking against ncurses instead of ncursesw. This is
    only useful on systems that have the ncursesw package installed
    incorrectly. On most systems this will cause compile- or run-time errors.
library
  hs-source-dirs: lib
  ghc-options: -Wall -O2
  include-dirs: cbits

  build-depends:
      base >= 4.6 && < 5.0
    , containers >= 0.2
    , text >= 0.7
    , transformers >= 0.2

  build-tools:
    c2hs >= 0.15

  if flag(use-pkgconfig)
    if flag(force-narrow-library)
      cc-options: -DHSNCURSES_NARROW_HEADER
      pkgconfig-depends: ncurses, panel
    else
      pkgconfig-depends: ncursesw, panelw
  else
    -- MacOS has a version of ncurses where the narrow- and wide-character
    -- builds have been merged into a single header/dylib.
    --
    -- Explicitly linking against libpthread.so fixes a build problem on
    -- platforms where the linker doesn't automatically follow dependencies.
    if os(darwin) || os(freebsd) || flag(force-narrow-library)
      cc-options: -DHSNCURSES_NARROW_HEADER
    if os(darwin) || flag(force-narrow-library)
      extra-libraries: panel ncurses pthread
    else
      extra-libraries: panelw ncursesw pthread

  c-sources: cbits/hsncurses-shim.c

  exposed-modules:
    UI.NCurses
    UI.NCurses.Panel

  other-modules:
    UI.NCurses.Enums
    UI.NCurses.Compat
    UI.NCurses.Types

【问题讨论】:

  • 注意有UI.NCurses.chs,需要用c2hs进行预处理。尽管.cabal 文件需要它,但您能否检查一下您的路径上是否安装了c2hs
  • 是的。 c2hs 已安装。

标签: haskell cabal


【解决方案1】:

我遇到了同样的问题。尽管安装了c2hs 并且在PATH 中,但我依赖的库安装失败并显示相同的错误消息。

对我来说,解决方案是在我想要构建的项目中运行 cabal clean,然后使用 cabal configure 重新配置它。

我怀疑在之前的构建过程中出现了问题,导致 cabal 认为 c2hs 运行正常,但在这种情况下却没有。

【讨论】:

    猜你喜欢
    • 2019-12-05
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    相关资源
    最近更新 更多