微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

macos – Haskell包缺少c库

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

正如建议的here我将内置类型从Custom更改为Simple. (没有那个改变我得到了类似的错误).

当我使用cabal配置时,我得到以下输出

* 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",("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",("Stage","2"),("Build platform","x86_64-apple-darwin"),("Host platform",("Target platform",("Have interpreter","YES"),("Object splitting supported",("Have native code generator",("Support SMP",("Unregisterised",("Tables next to code",("RTS ways","l debug  thr thr_debug thr_l thr_p  dyn debug_dyn thr_dyn thr_debug_dyn"),("Leading underscore",("Debug on",("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中正常工作.

原文地址:https://www.jb51.cc/c/119053.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐