无法使用 Cabal 安装 'ihaskell-diagrams'

Can't install 'ihaskell-diagrams' using Cabal

当我尝试

cabal install ihaskell-diagrams

我收到错误

The pkg-config package 'glib-2.0' is required but it could not be found.

什么是 glib 以及如何安装它以便它可用于 Cabal?


Resolving dependencies...
Configuring cairo-0.13.1.0...
Configuring glib-0.13.2.1...
Failed to install cairo-0.13.1.0
Build log ( /Users/Rax/.cabal/logs/cairo-0.13.1.0.log ):
[1 of 2] Compiling SetupWrapper     ( /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57646/cairo-0.13.1.0/SetupWrapper.hs, /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57646/cairo-0.13.1.0/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main             ( /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57646/cairo-0.13.1.0/dist/setup/setup.hs, /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57646/cairo-0.13.1.0/dist/setup/Main.o )
Linking /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57646/cairo-0.13.1.0/dist/setup/setup ...
[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 ...
Configuring cairo-0.13.1.0...
setup: The pkg-config package 'cairo' version >=1.2.0 is required but it could
not be found.
Failed to install glib-0.13.2.1
Build log ( /Users/Rax/.cabal/logs/glib-0.13.2.1.log ):
[1 of 2] Compiling SetupWrapper     ( /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57647/glib-0.13.2.1/SetupWrapper.hs, /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57647/glib-0.13.2.1/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main             ( /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57647/glib-0.13.2.1/dist/setup/setup.hs, /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57647/glib-0.13.2.1/dist/setup/Main.o )

Linking /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/cabal-tmp-57647/glib-0.13.2.1/dist/setup/setup ...
[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 ...
Configuring glib-0.13.2.1...
setup: The pkg-config package 'glib-2.0' is required but it could not be
found.
cabal: Error: some packages failed to install:
cairo-0.13.1.0 failed during the configure step. The exception was:
ExitFailure 1
diagrams-cairo-1.3.0.5 depends on glib-0.13.2.1 which failed to install.
glib-0.13.2.1 failed during the configure step. The exception was:
ExitFailure 1
ihaskell-diagrams-0.3.1.0 depends on glib-0.13.2.1 which failed to install.
pango-0.13.1.0 depends on glib-0.13.2.1 which failed to install.

此处的混淆源于可能不清楚的错误消息:缺少的组件不是 Cabal 包,而是需要单独安装的库。

其中一些库有自己的依赖项,或者安装它们可能会发现其他缺少的包,因此您的系统的具体要求可能会有所不同;但一般来说,当您收到缺少 "pig-config package" 的错误时,您需要使用包管理器(而不是 Cabal)安装它。

例如,

brew install glib
brew install cairo
brew install pango

为我工作,允许我

cabal install ihaskell-diagrams

没有更多错误。