gpt4 book ai didi

macos - Haskell 包缺少 c 库

转载 作者:行者123 更新时间:2023-12-04 12:41:44 25 4
gpt4 key购买 nike

我在 OS X Lion 上构建 hmatrix library 时遇到问题。查看 .cabal 文件,它需要 gsl 库,所以我用 macports 安装了它。 .a 文件位于/opt/local/lib 中,.h 文件位于/opt/local/include/gsl

正如 here 建议的那样,我将内置类型从自定义更改为简单。 (没有那个改变我得到一个类似的错误)。

当我使用 cabal configure 时,我得到以下输出:

* Missing C library: gsl
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.

所以我尝试了 cabal --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib configure ,但我仍然得到同样的错误。我可以编译和链接一个包含 gsl 的 c 程序。 cabal 正在寻找什么文件?如果我有正确的文件,我该如何告诉它如何找到它们?

libgsl.a 是一个通用二进制文件:
$ file /opt/local/lib/libgsl.a
/opt/local/lib/libgsl.a: Mach-O universal binary with 2 architectures
/opt/local/lib/libgsl.a (for architecture x86_64): current ar archive random library
/opt/local/lib/libgsl.a (for architecture i386): current ar archive random library

ghc 看起来像是 64 位的:
$ ghc --info
[("Project name","The Glorious Glasgow Haskell Compilation System")
,("GCC extra via C opts"," -fwrapv")
,("C compiler command","/usr/bin/llvm-gcc")
,("C compiler flags"," -m64 -fno-stack-protector -m64")
,("ar command","/usr/bin/ar")
,("ar flags","clqs")
,("ar supports at file","NO")
,("touch command","touch")
,("dllwrap command","/bin/false")
,("windres command","/bin/false")
,("perl command","/usr/bin/perl")
,("target os","OSDarwin")
,("target arch","ArchX86_64")
,("target word size","8")
,("target has GNU nonexec stack","False")
,("target has subsections via symbols","True")
,("Project version","7.4.2")
,("Booter version","7.4.2")
,("Stage","2")
,("Build platform","x86_64-apple-darwin")
,("Host platform","x86_64-apple-darwin")
,("Target platform","x86_64-apple-darwin")
,("Have interpreter","YES")
,("Object splitting supported","NO")
,("Have native code generator","YES")
,("Support SMP","YES")
,("Unregisterised","NO")
,("Tables next to code","YES")
,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn")
,("Leading underscore","YES")
,("Debug on","False")
,("LibDir","/usr/local/Cellar/ghc/7.4.2/lib/ghc-7.4.2")
,("Global Package DB","/usr/local/Cellar/ghc/7.4.2/lib/ghc-7.4.2/package.conf.d")
,("Gcc Linker flags","[\"-m64\"]")
,("Ld Linker flags","[\"-arch\",\"x86_64\"]")
]

最佳答案

作为 mac-ports 的替代方案,您可以使用 nix mac 包管理器。它在处理通过它可用的库的 c 依赖项方面做得很好。总的来说,我对它比 mac 上的任何其他包管理器都更满意。

不幸的是,mac(darwin) 与 linux 不同,没有通过 nix 提供的那么多二进制文件,因此安装 ghc 通常意味着等待它编译。

安装 nix 后安装 ghc 和 hmatrix 的命令是:

nix-env -iA nixpkgs-unstable.haskellPackages.ghc
nix-env -iA nixpkgs-unstable.haskellPackages.hmatrix

所有需要的依赖项都会为您处理好。

我刚刚在我的 macbook pro 上尝试过,在尝试了 tutorial 前几页的命令后,hmatrix 似乎在 ghci 中工作正常。 .

关于macos - Haskell 包缺少 c 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16291890/

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