在Windows上安装Cairo Haskell绑定失败。

4
我正在尝试在Windows 7上安装cairo-0.12.4 Haskell包。我首先下载并解压了Gtk+2,然后将其bin子目录添加到PATH中。然后我尝试使用额外的库和包含来运行cabal:
cabal --extra-lib-dirs="d:\Program Files (x86)\Gtk+\lib" 
      --extra-include-dirs="d:\Program Files (x86)\Gtk+\include" install

但是我遇到了以下错误。
 Reading available packages...
 Choosing modular solver.
 Resolving dependencies...
 Ready to install cairo-0.12.4
 Waiting for install task to finish...
 Extracting
 C:\Users\abailly\AppData\Roaming\cabal\packages\hackage.haskell.org\cairo\0.12.4\cairo-0.12.4.tar.gz
 to C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368...
 Updating cairo.cabal with the latest revision from the index.
 creating
 C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup
 creating
 C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist
 creating
 C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup
 d:\Program Files (x86)\Haskell Platform\2012.2.0.0\bin\ghc.exe --make C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-
 0.12.4\Setup.hs -o C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\setup.exe -odir C:\Users\abailly\
 AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup -hidir C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.
 12.4\dist\setup -i -iC:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4 -package Cabal-1.14.0
 [1 of 2] Compiling SetupWrapper     ( C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\SetupWrapper.hs, C:\Users
 \abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\SetupWrapper.o )
 [2 of 2] Compiling Main             ( C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\Setup.hs, C:\Users\abaill
 y\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\Main.o )
 Linking C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\setup.exe ...
 C:\Users\abailly\AppData\Local\Temp\cairo-0.12.4-2368\cairo-0.12.4\dist\setup\setup.exe
 configure --verbose=2 --ghc --prefix=C:\Users\abailly\AppData\Roaming\cabal
 --user --flags=cairo_svg --flags=cairo_ps --flags=cairo_pdf
 --extra-include-dirs=D:\Program Files (x86)\Gtk+\include
 --extra-lib-dirs=D:\Program Files (x86)\Gtk+\lib --constraint=mtl ==2.1.2
 --constraint=bytestring ==0.9.2.1 --constraint=base ==4.5.0.0
 --constraint=array ==0.4.0.0 --disable-tests --disable-benchmarks
 [1 of 2] Compiling Gtk2HsSetup      ( Gtk2HsSetup.hs, dist\setup-wrapper\Gtk2HsSetup.o )
 [2 of 2] Compiling Main             ( SetupMain.hs, dist\setup-wrapper\Main.o )
 Linking dist/setup-wrapper\setup.exe ...
 Configuring cairo-0.12.4...
 Flags chosen: cairo_svg=True, cairo_ps=True, cairo_pdf=True
 Dependency array ==0.4.0.0: using array-0.4.0.0
 Dependency base ==4.5.0.0: using base-4.5.0.0
 Dependency bytestring ==0.9.2.1: using bytestring-0.9.2.1
 Dependency mtl ==2.1.2: using mtl-2.1.2
 Dependency cairo-pdf -any: using version 1.10.2
 Dependency cairo-ps -any: using version 1.10.2
 Dependency cairo-svg -any: using version 1.10.2
 Dependency cairo >=1.2.0: using version 1.10.2
 Using Cabal-1.14.0 compiled by ghc-7.4
 Using compiler: ghc-7.4.1
 Using install prefix: C:\Users\abailly\AppData\Roaming\cabal
 Binaries installed in: C:\Users\abailly\AppData\Roaming\cabal\bin
 Libraries installed in:
 C:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4\ghc-7.4.1
 Private binaries installed in:
 C:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4
 Data files installed in: C:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4
 Documentation installed in:
 C:\Users\abailly\AppData\Roaming\cabal\doc\cairo-0.12.4
 Using alex version 3.0.1 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\lib\extralibs\bin\alex.exe
 Using ar found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\mingw\bin\ar.exe
 No c2hs found
 Using cpphs version 1.16 found on system at:
 c:\Users\abailly\AppData\Roaming\cabal\bin\cpphs.exe
 No ffihugs found
 Using gcc version 4.5.2 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\mingw\bin\gcc.exe
 Using ghc version 7.4.1 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\bin\ghc.exe
 Using ghc-pkg version 7.4.1 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\bin\ghc-pkg.exe
 No greencard found
 Using gtk2hsC2hs version 0.13.6 found on system at:
 c:\Users\abailly\AppData\Roaming\cabal\bin\gtk2hsC2hs.exe
 Using gtk2hsHookGenerator found on system at:
 c:\Users\abailly\AppData\Roaming\cabal\bin\gtk2hsHookGenerator.exe
 Using gtk2hsTypeGen found on system at:
 c:\Users\abailly\AppData\Roaming\cabal\bin\gtk2hsTypeGen.exe
 Using haddock version 2.10.0 found on system at: d:\Program Files
 (x86)\Haskell Platform\2012.2.0.0\bin\haddock.exe
 Using happy version 1.18.9 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\lib\extralibs\bin\happy.exe
 No hmake found
 Using hpc version 0.6 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\bin\hpc.exe
 Using hsc2hs version 0.67 found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\bin\hsc2hs.exe
 Using hscolour version 1.20 found on system at:
 c:\Users\abailly\AppData\Roaming\cabal\bin\HsColour.exe
 No hugs found
 No jhc found
 Using ld found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\mingw\bin\ld.exe
 No lhc found
 No lhc-pkg found
 No nhc98 found
 Using pkg-config version 0.26 found on system at: d:\Program Files
 (x86)\Gtk+\bin\pkg-config.exe
 Using ranlib found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\mingw\bin\ranlib.exe
 Using strip found on system at: d:\Program Files (x86)\Haskell
 Platform\2012.2.0.0\mingw\bin\strip.exe
 Using tar found on system at: D:\Program Files (x86)\Git\bin\tar.exe
 No uhc found
 d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-pdf
 d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-ps
 d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-svg
 d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo
 setup.exe: Missing dependencies on foreign libraries:
 * Missing C libraries: z, cairo
 This problem can usually be solved by installing the system packages that
 provide these libraries (you may need the "-dev" versions). If the libraries
 are already installed but in a non-standard location then you can use the
 flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.
 Failed to install cairo-0.12.4
 cabal.exe: Error: some packages failed to install:
 Chart-0.16 depends on cairo-0.12.4 which failed to install.
 cairo-0.12.4 failed during the configure step. The exception was:
 ExitFailure 1
 splot-0.3.8 depends on cairo-0.12.4 which failed to install.

当我尝试直接安装cairo时,出现以下情况:

d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-pdf
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-ps
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo-svg
d:\Program Files (x86)\Gtk+\bin\pkg-config.exe --modversion cairo
setup.exe: Missing dependencies on foreign libraries:
* Missing C libraries: z, cairo
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.
Failed to install cairo-0.12.4
World file is already up to date.
cabal.exe: Error: some packages failed to install:
cairo-0.12.4 failed during the configure step. The exception was:
ExitFailure 1

我一点头绪也没有...

3个回答

4
如果你看到错误信息:
* Missing C libraries: z, cairo

它说您需要安装库(和头文件)libz和cairo的库。在*nix系统上,这通常意味着使用软件包管理器仅安装这些软件包的-dev版本。在Windows上,我假设您将下载库的源版本并进行安装。


谢谢您的回答。正如我所说,我下载了包含DLL和头文件的gitk+ 组合包。据我所知,这些库存在于我的系统中的D:\Program Files (x86)\Gtk+\目录中:
  • z -> include\zlib.h
  • cairo -> include\cairo\cairo.h
  • cairo.lib -> lib\
  • zdll.lib -> lib\
我调整了cabal命令行,将DLL和包含路径添加到了cabal中。因此让我感到困惑...
- insitu
顺便说一下,我查看了在Windows上从源代码构建cairo的方法,但由于我认为预编译的二进制包已经足够满足我的需求,所以我还没有尝试过。当然,我可能是错的。 - insitu
无论您下载的GTK库的意图是什么,情况似乎是您的(cabal)构建不知道在哪里找cairo或z。这可能需要一些摆弄才能弄清楚原因。 - Thomas M. DuBuisson
我明白。但是我希望从比我更有经验的人那里得到一些“调整方向”的建议 :-) 无论如何,谢谢。 - insitu

2

我遇到了一个问题。在我的情况下,这是由于一个64位的ghc和一个32位的cairo dll版本不匹配造成的。


1

我将Gtk+库移动到D:\soft\gtk+\,一切都运行正常。Gtk+路径中包含空格,cabal/ghc似乎无法正确解释它,尽管我已经使用了双引号:

--extra-lib-dirs="d:\Program Files (x86)\Gtk+\lib"

解决方案: 将gtk+安装在无空格的位置。

更新: 现在,安装Chart-0.16失败并显示更加神秘的错误信息:

Loading package Win32-2.2.2.0 ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package old-locale-1.0.0.4 ... linking ... done.
Loading package time-1.4 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package data-accessor-0.2.2.3 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package utility-ht-0.0.8 ... linking ... done.
Loading package data-accessor-template-0.2.1.10 ... linking ... done.
Loading package colour-2.3.3 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
*** gcc:
"D:\Program Files (x86)\Haskell Platform\2012.2.0.0\lib/../mingw/bin/gcc.exe" "-fno-stack-protector" "-Wl,--hash-size=31" "-Wl,--r
educe-memory-overheads" "-LC:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4\ghc-7.4.1" "-Ld:/soft/Gtk+/lib" "--print-file-name"
 "libz.dll"
*** gcc:
"D:\Program Files (x86)\Haskell Platform\2012.2.0.0\lib/../mingw/bin/gcc.exe" "-fno-stack-protector" "-Wl,--hash-size=31" "-Wl,--r
educe-memory-overheads" "-LC:\Users\abailly\AppData\Roaming\cabal\cairo-0.12.4\ghc-7.4.1" "-Ld:/soft/Gtk+/lib" "--print-file-name"
 "libcairo-2.dll"
Loading package cairo-0.12.4 ... d:\Program Files (x86)\Haskell Platform\2012.2.0.0\bin\ghc.exe returned
ExitFailure 1
Failed to install Chart-0.16
cabal.exe: Error: some packages failed to install:
Chart-0.16 failed during the building phase. The exception was:
ExitFailure 1
splot-0.3.8 depends on Chart-0.16 which failed to install.

我怀疑这是由于链接错误导致的,因为当我执行以下命令时,编译可以正常运行,这就是cabal在调试模式下输出的内容:

 "D:\\Program Files (x86)\\Haskell Platform\\2012.2.0.0\\bin\\ghc.exe"
 "--make" "-v" "-fbuilding-cabal-package" "-O" "-odir" "dist\\build"
 "-hidir" "dist\\build" "-stubdir" "dist\\build" "-i" "-idist\\build"
 "-i." "-idist\\build\\autogen" "-Idist\\build\\autogen"
 "-Idist\\build" "-optP-include"
 "-optPdist\\build\\autogen\\cabal_macros.h" "-package-name"
 "Chart-0.16" "-hide-all-packages" "-package-conf"
 "dist\\package.conf.inplace" "-package-id"
 "array-0.4.0.0-3cf1bc3f5cd0078adea24752c18081b9" "-package-id"
 "base-4.5.0.0-597748f6f53a7442bcae283373264bb6" "-package-id"
 "cairo-0.12.4-f04021ea456c901e8d05395a31f7a861" "-package-id"
 "colour-2.3.3-4eaa610bb6d825a7334e1b3de448f6c0" "-package-id"
 "data-accessor-0.2.2.3-5477c48e3478339fdff299c536a033c6" "-package-id"
 "data-accessor-template-0.2.1.10-28ee96821fd908880f3a49417c4da548"
 "-package-id" "mtl-2.1.2-7ec8bbada2af74b49c6e4aeea2889fdc"
 "-package-id" "old-locale-1.0.0.4-29bd50ed2bb4a20928338f52e4ab1b71"
 "-package-id" "time-1.4-01d7bf22d87e70510fe9ee4c4434b3ab"
 "-XHaskell98" "Graphics.Rendering.Chart"
 "Graphics.Rendering.Chart.Types" "Graphics.Rendering.Chart.Renderable"
 "Graphics.Rendering.Chart.Axis"
 "Graphics.Rendering.Chart.Axis.Floating"
 "Graphics.Rendering.Chart.Axis.Indexed"
 "Graphics.Rendering.Chart.Axis.Int"
 "Graphics.Rendering.Chart.Axis.LocalTime"
 "Graphics.Rendering.Chart.Axis.Types"
 "Graphics.Rendering.Chart.Axis.Unit" "Graphics.Rendering.Chart.Layout"
 "Graphics.Rendering.Chart.Legend" "Graphics.Rendering.Chart.Simple"
 "Graphics.Rendering.Chart.Simple.Internal"
 "Graphics.Rendering.Chart.Grid" "Graphics.Rendering.Chart.Plot"
 "Graphics.Rendering.Chart.Plot.Types"
 "Graphics.Rendering.Chart.Plot.Annotation"
 "Graphics.Rendering.Chart.Plot.AreaSpots"
 "Graphics.Rendering.Chart.Plot.Bars"
 "Graphics.Rendering.Chart.Plot.Candle"
 "Graphics.Rendering.Chart.Plot.ErrBars"
 "Graphics.Rendering.Chart.Plot.FillBetween"
 "Graphics.Rendering.Chart.Plot.Hidden"
 "Graphics.Rendering.Chart.Plot.Lines"
 "Graphics.Rendering.Chart.Plot.Pie"
 "Graphics.Rendering.Chart.Plot.Points"
 "Graphics.Rendering.Chart.SparkLine" "-hide-package" "monads-tf" 

我更加困惑了... 更新(2):当我运行cabal install > out 2>&1时,它成功了!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接