【问题标题】:"requested module differs from name found in the interface file"“请求的模块与接口文件中的名称不同”
【发布时间】:2014-10-04 01:36:37
【问题描述】:

我想要的是:cabal 来构建我的模块; make 构建这个脚本。

脚本链接到 Objective-C(参见 https://github.com/mchakravarty/language-c-inline/tree/master/tests/objc/marshal-array)。当我构建脚本时,导入失败:

$ make
Main.hs:1:1:
    Bad interface file: dist/build/Commands/OSX/Events.hi
        Something is amiss; requested module  main:Commands.OSX.Events differs from name found in the interface file commands-0.0.0:Commands.OSX.Events

这里是一些文件内容:

$ cat Makefile
PACKAGES   = -package template-haskell -package language-c-quote -package language-c-inline -package commands
FRAMEWORKS = -framework Carbon -framework Cocoa -framework Foundation
LDFLAGS    = $(PACKAGES) $(FRAMEWORKS) 
Main: Main.o
    cabal exec -- ghc  -o Main Main.o $(LDFLAGS)
Main.o:
    cabal build
    cabal exec -- ghc  -c Main.hs -idist/build/ -v
...

$ cat commands.cabal
 exposed-modules: Commands.OSX.Events
 hs-source-dirs: sources
...

$ ghc --show-iface dist/build/Commands/OSX/Events.hi
interface commands-0.0.0:Commands.OSX.Events 7083
...

$ cat sources/Commands/OSX/Events.hs
module Commands.OSX.Events where
...

$ cat Main.hs
import Commands.OSX.Events
...

如果我只是将所有内容放在同一个目录中,而忽略 cabal,则 cabal 构建成功,可执行文件编译并运行成功。

  1. 我可以告诉 GHC 某个模块是某个包的一部分吗?

  2. 我可以使用这些外部依赖项制作 cabal 可执行文件吗?

  3. 还有其他解决方案吗?

【问题讨论】:

    标签: haskell ghc cabal


    【解决方案1】:

    明确命名模块包的名称:

    ghc -package-name commands-0.0.0
    

    http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/packages.html

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 2014-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多