gpt4 book ai didi

Haskell/Stack/Nix 构建失败,需要 pkg-config >= 0.9.0 和 cairo >= 1.2.0,但最新版本是 pkg-config 0.29.2 和 cairo 1.15.4

转载 作者:行者123 更新时间:2023-12-01 10:29:23 25 4
gpt4 key购买 nike

我正在使用 Stack 和 Nix 构建一个 Haskell 项目,并依赖于来自 Hackage 的 cairo 库。

当我构建项目时,出现错误:无法找到 pkg-config >= 0.9.0cairo >= 1.2.0。然而,根据他们的网站,最新版本是 pkg-config 0.29.2cairo-1.15.4,这也反射(reflect)在 Nix 包管理器中。

另一方面, this article from 2006 announcing the release of Cairo 1.2.0 ,这进一步混淆了这个问题。

问题

  1. Why are the expected versions so wildly different from the published versions on nixpkgs and the pkg-config / cairo websites?

  2. What advice do you have to get cairo to build on macOS (best case scenario: using Nix for system packages and Stack for Haskell packages)

重现步骤:

> stack new cairo-test simple && cd cairo-test

# Now, to get Cairo
> stack install cairo

cairo-0.13.3.1: configure ...
Process exited with code: ExitFailure 1
Configuring cairo-0.13.3.1...
setup: The program 'pkg-config' version >=0.9.0 is required but it could not be found.

# This version doesn't seem to exist (not on the pkg-config website, either).
> nix-env -qaP pkg-config
nixpkgs.pkgconfig pkg-config-0.29.2
nixpkgs.pkgconfigUpstream pkg-config-0.29.2

# However, if installed, a new error:
> nix-env -i pkg-config
installing ‘pkg-config-0.29.2’
building path(s) ‘/nix/store/m4ks2si7b78757c1rc43r0833pxkvjb3-user-environment’
created 102 symlinks in user environment
> stack install cairo
setup: The pkg-config package 'cairo' version >=1.2.0 is required but
it could not be found.

# Again, this version doesn't seem to exist, either on the site on in `nixpkgs`
> nix-env -qaP cairo
nixpkgs.cairo cairo-1.14.8

# Installing it anyway, to see what the next error is
> nix-env -i cairo
installing ‘cairo-1.14.8’
building path(s) ‘/nix/store/dcx0in96wcd7yd8q71y93jd5306vag8g-user-environment’
created 112 symlinks in user environment

# Get the same version error now that Cairo is installed
setup: The pkg-config package 'cairo' version >=1.2.0 is required but it could not be found.

最佳答案

问题不是库版本,1.14.8 大于 1.2.0。问题是 cairo 开发文件没有链接到您的环境中,也就是说,$PKG_CONFIG_PATH 没有设置。

三种解决方案:

  1. /nix/store 中找到cairo-dev 目录,并将其添加到PKG_CONFIG_PATH。例如,

     $ cairodev=$(nix-store --query --outputs $(nix-instantiate '<nixpkgs>' -A cairo) | grep dev$)
    $ export PKG_CONFIG_PATH=$cairodev:$PKG_CONFIG_PATH
  2. 从 nix shell 中运行堆栈,nix-shell -p pkgconfig cairo

  3. 通过将以下内容添加到 stack.yml 来使用 stack 的 nix 支持:

    nix:
    enable: true
    packages: [pkgconfig, cairo]

关于Haskell/Stack/Nix 构建失败,需要 pkg-config >= 0.9.0 和 cairo >= 1.2.0,但最新版本是 pkg-config 0.29.2 和 cairo 1.15.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44314060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com