2013-04-30 132 views
7

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

如建议here我将内置类型从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的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\"]") 
] 
+0

在黑暗中完成拍摄:你有安装g ++吗?我记得安装了一个不同的库,并得到类似的奇怪的错误信息(它也没有找到明确安装的C库);后来证明它也需要g ++。 – 2013-04-30 04:03:12

+0

我确实安装了g ++。 – munk 2013-04-30 04:06:40

+1

您是否尝试过'cabal install -v hmatrix'来查看失败的步骤?这可能有助于缩小问题的范围。 – 2013-05-01 11:39:23

回答

2

作为mac端口的替代方案,您可以使用nix软件包管理器for mac。它在为通过它提供的库提供依赖方面做得相当不错。总的来说,我对Mac上的其他软件包管理器感到非常满意。

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

安装尼克斯的后安装GHC和HMATRIX的命令是:

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

所有需要的依赖将采取为你照顾。

我刚刚尝试过我的MacBook Pro和hmatrix似乎在尝试命令从tutorial的前几页后ghci正常工作。

+0

我没有最终使用nix,但是当我尝试构建它时,我发现与我使用的gcc版本存在差异。这肯定会让我找到解决方案。谢谢! – munk 2013-05-01 12:12:55

+0

@usmcs非常高兴它帮助。 – Davorak 2013-05-01 17:04:25

1

我不是一个MAC的人,但它确实听起来像你的天堂” t安装了“-dev”版本。对于mac,我怀疑除了gsl之外,还需要安装gsl-devel。如果问题仍然存在,请验证您的库路径上是否有libgsl0-dev

+0

我确实使用'port install gsl-devel + universal'安装了-dev版本。我将检查libgsl0-dev的位置。 – munk 2013-04-30 17:36:13

+0

我的系统上没有libgsl0-dev任何位置。是什么让这个不同于libgsl? – munk 2013-05-01 02:10:14

+0

嗯。你有任何形式的文件名'libgsl?-dev'?我不知道'libgsl0-dev'中的'0'是否重要,但我认为'-dev'位是。通常你需要库的'-dev'版本来对它进行任何开发。安装'gsl-devel'可能会出错。 – mhwombat 2013-05-01 11:21:51