【问题标题】:Installing Cairo, Helm on Windows在 Windows 上安装 Cairo、Helm
【发布时间】:2015-11-26 03:41:37
【问题描述】:

如何在 Windows 7(64 位)上安装 Helm (https://hackage.haskell.org/package/helm)?

(更新:我在这里发布了很多错误消息,但我已将它们移至我的答案中,以免混淆问题。)

【问题讨论】:

    标签: cairo cabal-install


    【解决方案1】:

    Windows 64 位安装:

    我将包含错误消息,因为如果您按照所有步骤进行操作,然后尝试直接安装。这是遵循许多不同帖子的一系列临时步骤的集合。任何简化将不胜感激!

    注意:在没有空格的目录中完成所有工作。我在 C:/PF 中完成所有工作;将此修改为您的目录。

    1. https://msys2.github.io/ 下载 MSYS2-x86_64 并安装它。 Cabal install cairo(或 helm)会给出类似的东西:

      正在配置 cairo-0.13.1.0... setup.exe:缺少对外部库的依赖:

      • 缺少 C 库:z、cairo、z、gobject-2.0、ffi、pixman-1、fontconfig、 expat,freetype,iconv,expat,freetype,z,bz2,harfbuzz,glib-2.0,intl, ws2_32, ole32, winmm, shlwapi, intl, png16, z
    2. 下载 C 库。在 MINGW64 中(不是 MSYS2 - 我在过程中的随机阶段遇到了 MSYS2 问题),使用包管理器:

      pacman -Ss 开罗

    搜索 Cairo 包。你会找到“mingw64/mingw-w64-x86_64-cairo”,所以安装它:

    pacman -S mingw64/mingw-w64-x86_64-cairo
    

    *.pc 文件应该已添加到 C:\PF\msys64\mingw64\lib\pkgconfig 和 C:\PF\msys64\usr\lib\pkgconfig。 (pkg-config 需要能够找到这些文件。它在 PKG_CONFIG_PATH 中查找,默认情况下应该有上面的 lib/pkgconfig 文件夹。将文件移到这里是最简单的。见Can't install sdl2 via cabal)如果你得到

    The pkg-config package ... version ... cannot be found 
    

    然后检查您的 *.pc 文件。

    重复使用其他必需的库,例如 atk

    pacman -S mingw64/mingw-w64-x86_64-atk
    

    (我不知道完整列表,但稍后的错误消息会让您知道要获得什么。)

    1. 获取这些库的开发文件(如How to install cairo on Windows 建议的那样)。其中大部分都捆绑在http://ftp.gnome.org/pub/gnome/binaries/win64/gtk+/2.22/。解压缩。

      • 将 lib 中的文件(.a、.dll.a)复制到 C:\PF\msys64\mingw64\lib。复制包含 .pc 文件的 pkgconfig 文件夹。
      • 将 include 中的文件复制到 C:\PF\msys64\mingw64\include。
      • 将 C:\PF\gtk+-2.22.1\bin 添加到路径中。

    (2) 和 (3) 可能是多余的。我不知道 - 我都做过。

    此时您可能可以执行“cabal install cairo”。 (警告:如果您的最终目标是别的,您可能不想“阴谋安装”中间包,请参阅https://wiki.haskell.org/Cabal/Survival#Issue_.232_--_Not_installing_all_the_packages_in_one_go。) 指定extra-include-dirs 和extra-lib-dirs 的语法见(4)(但如果你复制了上面的文件,这应该是没有必要的),

    只要你得到

    Missing (or bad) header file
    

    检查您是否已将 *.h 文件复制到 mingw64\include 和/或将包含文件夹添加到 PATH。如果问题仍然存在,请使用 cabal install -v3 获取详细的错误消息。

    如果你得到类似的东西

    cairo-0.13.1.0: include-dirs: /mingw64/include/freetype2 is a relative path
    which makes no sense (as there is nothing for it to be relative to). You can
    make paths relative to the package database itself by using ${pkgroot}. (use
    --force to override)
    

    尝试--ghc-pkg-options="--force"(如https://github.com/gtk2hs/gtk2hs/issues/139 所述)。

    1. 获取 SDL。否则你会得到

      配置:错误:*** SDL 未找到!从 www.libsdl.org 获取 SDL。 如果您已经安装了它,请检查它是否在路径中。如果问题仍然存在, 请向 ./configure --version 中显示的地址发送邮件 指示您的平台、配置脚本的版本和问题。 安装 SDL-0.6.5.1 失败

    按照 (2) 中的说明获取 sdl/sdl2 库。 (请参阅此处的说明Installing SDL on Windows for Haskell (GHC)。)

    新版本 helm-0.7.1 需要 sdl2,但在撰写本文时 helm-0.7.1 还存在其他依赖问题。从http://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/下载SDL(直接下载链接到最新版本http://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/mingw-w64-x86_64-SDL-1.2.15-7-any.pkg.tar.xz.sig/download),解压。 “cabal install sdl”给出了

    * Missing (or bad) header file: SDL/SDL.h
    * Missing C library: SDL
    This problem can usually be solved by installing the system package that
    provides this library (you may need the "-dev" version). If the library is
    already installed but in a non-standard location then you can use the flags
    --extra-include-dirs= and --extra-lib-dirs= to specify where it is.
    

    所以我们指定目录的位置(根据您将 sdl 提取到的位置更改名称)

    cabal install sdl --extra-include-dirs=C:/PF/sdl\include --extra-lib-dirs=C:/sdl/lib
    

    如果您获得了 SDL2 (http://libsdl.org/download-2.0.php)(对于较新版本的 Helm):发布版本中存在一个尚未修复的致命错误。 (如果你不修复它,依赖它的 cabal install -v3 things 会报错

    winapifamily.h: No such file or directory 
    

    ("winapifamily.h: No such file or directory" when compiling SDL in Code::Blocks) 下载https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h,替换include文件夹和C:/PF/msys64/mingw64/include/SDL2中的文件。

    1. http://code.haskell.org/gtk2hs下载gtk2hs并运行

    以下

    cd gtk2hs/tools
    cabal install
    cd ../glib
    cabal install
    cd ../gio
    cabal install
    cd ../pango
    cabal install --ghc-pkg-options="--force"
    

    (也许您之前已经安装了 glib 和 gio?我执行此步骤是因为正常安装 Pango 对我造成了错误(https://github.com/gtk2hs/gtk2hs/issues/110

    pango-0.13.1.0: include-dirs: /mingw64/include/freetype2 is a relative path
    which makes no sense (as there is nothing for it to be relative to). You can
    make paths relative to the package database itself by using ${pkgroot}. (use
    --force to override)
    
    1. 一旦 Helm 开发人员得到更新,您应该能够执行“cabal install helm”,但现在似乎存在依赖性问题。对我来说,cabal 会自动尝试安装 helm-0.4(可能是因为 0.4 没有给出依赖的上限,而较新的版本有。你可以尝试“cabal unpack”并删除上限......)。那么

      cabal 解压 helm-0.4

    安装会出错,因为“纯”已移至 Prelude。打开 helm-0.4\src\FRP\Helm\Automaton.hs 并更改第 17 行:

    import Prelude hiding (id, (.), pure)
    

    现在

    cabal install
    
    1. 尝试使用 Helm 编译和运行程序

    (这是 0.4 - 如果您尝试了更新的 Helm,请在网站上查找更新的示例)

    import FRP.Helm
    import qualified FRP.Helm.Window as Window
    
    render :: (Int, Int) -> Element
    render (w, h) = collage w h [filled red $ rect (fromIntegral w) (fromIntegral h)]
    
    main :: IO ()
    main = run $ fmap (fmap render) Window.dimensions
    

    如果您收到有关缺少 .dll (sdl.dll) 的错误,请在 bin/ 文件夹中找到它并将该文件夹添加到您的 PATH(或将其复制到路径上的某个位置)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-01
      • 2013-02-17
      • 2011-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多