【问题标题】:Stack fails to compile under windowswindows下stack编译失败
【发布时间】:2017-12-11 23:36:15
【问题描述】:

我有一个相当麻烦的错误阻止我在 Windows 下构建我的一个小型 Haskell 项目,which you can find here if you want to try to compile it。我在 cygwin64 下。

根据given on this post 的建议,我使用堆栈作为构建助手。 现在,构建快要结束了(尝试了几个小时后,这相当令人沮丧)。

错误信息如下:

setup.exe:
'C:\Users\Julien\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin\ghc-pkg.EXE'
exited with an error:
cairo-0.13.4.2: Warning: haddock-interfaces:
C:\cygwin64\tmp\stack11608\cairo-0.13.4.2\.stack-work\dist\ca59d0ab\doc\html\cairo\cairo.haddock
doesn't exist or isn't a file
cairo-0.13.4.2: Warning: haddock-html:
C:\cygwin64\tmp\stack11608\cairo-0.13.4.2\.stack-work\dist\ca59d0ab\doc\html\cairo
doesn't exist or isn't a directory
cairo-0.13.4.2: include-dirs: /usr/include/cairo 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)
cairo-0.13.4.2: include-dirs: /usr/include/glib-2.0 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)
cairo-0.13.4.2: include-dirs: /usr/lib/glib-2.0/include 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)
cairo-0.13.4.2: include-dirs: /usr/include/pixman-1 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)
cairo-0.13.4.2: include-dirs: /usr/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)
cairo-0.13.4.2: include-dirs: /usr/include/libpng16 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)


--  While building custom Setup.hs for package glib-0.13.5.0 using:
  C:\cygwin64\tmp\stack11608\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\setup --builddir=.stack-work\dist\ca59d0ab build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: C:\cygwin64\home\Julien\syme-master\.stack-work\logs\glib-0.13.5.0.log

[1 of 2] Compiling Main             ( C:\cygwin64\tmp\stack11608\glib-0.13.5.0\Setup.hs, C:\cygwin64\tmp\stack11608\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\Main.o )
[2 of 2] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs, C:\cygwin64\tmp\stack11608\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\StackSetupShim.o )
Linking C:\cygwin64\tmp\stack11608\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\setup.exe ...
Configuring glib-0.13.5.0...
Building glib-0.13.5.0...
In file included from C:/cygwin64/usr/include/glib/gtypes.h:34:0,
                 from C:/cygwin64/usr/include/glib/galloca.h:32,
                 from C:/cygwin64/usr/include/glib.h:30,
                 from C:/cygwin64/usr/include/gobject/gbinding.h:28,
                 from C:\cygwin64\home\Julien\syme-master\../../../usr/include\glib-object.h:23:
C:/cygwin64/usr/include/glib/gversionmacros.h:257:2: error: #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"
 #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"
  ^
Preprocessing library glib-0.13.5.0...
setup.exe: Error during preprocessing

关键是根据cygwin安装程序,我安装了libglib2.0-devel 2.52.3-1版本。是 glib2 的错误版本吗?其他 glib 版本之间有冲突吗?如果是这样,我怎样才能让堆栈理解检查 正确的版本在哪里?

不得不说我在stack.yaml文件里面加了相对路径有点搞砸了,不知道是不是很麻烦。

任何帮助将不胜感激。

UDPATE:按照 cmets 的建议,我更改了我的项目本地 stack.yaml 以添加以下内容(我花了一段时间才弄清楚如何在 Windows 上编写路径)

extra-include-dirs: [c;\\cygwin64\\usr\\include]
extra-lib-dirs: [c;\\cygwin64\\lib]

在其中,我解压缩了 cmets 中提供的链接 user2407038 提供的库。现在,错误消息如下所示:

--  While building custom Setup.hs for package cairo-0.13.4.2 using:
  C:\cygwin64\tmp\stack10676\cairo-0.13.4.2\.stack-work\dist\ca59d0ab\setup\setup --builddir=.stack-work\dist\ca59d0ab build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: C:\cygwin64\home\Julien\syme-master\.stack-work\logs\cairo-0.13.4.2.log

[1 of 2] Compiling Main             ( C:\cygwin64\tmp\stack10676\cairo-0.13.4.2\Setup.hs, C:\cygwin64\tmp\stack10676\cairo-0.13.4.2\.stack-work\dist\ca59d0ab\setup\Main.o )
[2 of 2] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs, C:\cygwin64\tmp\stack10676\cairo-0.13.4.2\.stack-work\dist\ca59d0ab\setup\StackSetupShim.o )
Linking C:\cygwin64\tmp\stack10676\cairo-0.13.4.2\.stack-work\dist\ca59d0ab\setup\setup.exe ...
Configuring cairo-0.13.4.2...
Building cairo-0.13.4.2...
C:\cygwin64\tmp\stack10676\cairo-0.13.4.2\cairo-gtk2hs.h:1:18: fatal error: cairo.h: No such file or directory
compilation terminated.
Preprocessing library cairo-0.13.4.2...
setup.exe: Error during preprocessing


-- While building custom Setup.hs for package glib-0.13.5.0 using:
C:\cygwin64\tmp\stack10676\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\setup --builddir=.stack-work\dist\ca59d0ab build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: C:\cygwin64\home\Julien\syme-master\.stack-work\logs\glib-0.13.5.0.log

[1 of 2] Compiling Main             ( C:\cygwin64\tmp\stack10676\glib-0.13.5.0\Setup.hs, C:\cygwin64\tmp\stack10676\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\Main.o )
[2 of 2] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs, C:\cygwin64\tmp\stack10676\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\StackSetupShim.o )
Linking C:\cygwin64\tmp\stack10676\glib-0.13.5.0\.stack-work\dist\ca59d0ab\setup\setup.exe ...
Configuring glib-0.13.5.0...
Building glib-0.13.5.0...
Preprocessing library glib-0.13.5.0...
setup.exe: glib-object.h: File does not exist

在哪里可以找到这些标题?

【问题讨论】:

  • 那些(afaik)不是相对路径,而是 Unix/Linux 路径,显然编译器无法理解这些。
  • 您不能真正将 cygwin 与 GHC 一起使用,因为在 Windows 上,GHC 将期望在 Windows 环境中。特别是,您无法让 GHC 将路径 /usr/include/cairo 识别为有效的 Windows 路径(因为它不是)。您必须安装 glib 的本机版本(对于任何其他依赖项也是如此)并确保 GHC 不使用 cygwin gcc(通常堆栈做得很好)。另请注意,您的构建并没有在接近尾声时失败,它基本上在一开始就失败了(在构建依赖项时,甚至不是您的包)。
  • @user2407038 本地包,你的意思是 Windows 包?因为我在寻找适用于 Windows 的 glib 可用版本,但我没有找到任何...
  • Here 是 glib 源;如果您喜欢冒险,可以尝试自己构建它。否则,您必须在 Internet 上的某处找到预构建的二进制文件(快速谷歌搜索出现 this
  • 我希望您能找到在 Windows 上从头开始安装 Stack 的详细说明。你找过那些吗?

标签: windows haskell compilation glib haskell-stack


【解决方案1】:

我会看看 gtk2hs 的 windows 安装说明:https://wiki.haskell.org/Gtk2Hs/Installation#Windows

您可以直接下载捆绑包(从https://www.gtk.org/download/windows.php),或使用与平台安装的msys 发行版一起分发的pacman 安装它。

你应该使用 msys 版本或独立版本,而不是 cywin 版本,因为 ghc 是为 msys 而不是 cygwin 而构建的。

完成后,您应该能够正确设置路径,cabal install cairo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-07
    • 2012-05-04
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-09
    相关资源
    最近更新 更多