Haskell包缺少c库
我在OS X Lion上构建hmatrix库时遇到了问题。 看看.cabal文件,它需要gsl
库,所以我使用macports安装它。 .a文件位于/ opt / local / lib中,.h文件位于/ opt / local / include / gsl中
正如我在这里所建议的,我将Custom类型从Custom改为Simple。 (没有这种变化,我得到了类似的错误)。
当我使用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的ac程序。 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端口的替代品,您可以使用mac的nix包管理器。 它在为通过它提供的库提供依赖方面做得相当不错。 总的来说,我对Mac上的其他软件包管理器感到非常满意。
不幸的是,与linux不同的是,mac(darwin)没有像nix那样多的二进制文件,所以安装ghc通常意味着等待它编译。
在安装nix之后安装ghc和hmatrix的命令是:
nix-env -iA nixpkgs-unstable.haskellPackages.ghc
nix-env -iA nixpkgs-unstable.haskellPackages.hmatrix
所有需要的依赖关系都将为您照顾。
我刚刚在我的MacBook Pro上尝试过,并且在尝试从本教程的前几页中的命令后,hmatrix似乎在ghci中正常工作。
我不是一个mac人,但它听起来好像你没有安装“-dev”版本。 对于mac,我怀疑除了gsl
之外,你还需要安装gsl-devel
。 如果问题仍然存在,请验证您的库路径上是否有libgsl0-dev
。