Macos Haskell包缺少c库

Macos Haskell包缺少c库,macos,haskell,cabal,Macos,Haskell,Cabal,我在OS X Lion上构建时遇到问题。查看.cabal文件,它需要gsl库,因此我使用macports安装了它。.a文件位于/opt/local/lib中,.h文件位于/opt/local/include/gsl中 根据建议,我将构建类型从自定义更改为简单。(如果没有这个改变,我会得到一个类似的错误) 当我使用cabal configure时,我得到以下输出: * Missing C library: gsl This problem can usually be solved by inst

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

根据建议,我将构建类型从自定义更改为简单。(如果没有这个改变,我会得到一个类似的错误)

当我使用
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程序。阴谋集团在找什么文件?如果我有正确的文件,我如何告诉它如何找到它们

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用户,但听起来你还没有安装“-dev”版本。对于mac,我怀疑您需要安装
gsl-devel
以及
gsl
。如果问题仍然存在,请验证库路径上是否有
libgsl0 dev

作为mac端口的替代方案,您可以使用mac软件包管理器。它很好地处理了通过它提供的库的c依赖性。总的来说,我对它比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中正常工作。

g++是否已安装?我记得安装了一个不同的库,收到了类似的奇怪错误消息(也没有找到明显安装的C库);后来发现它也需要g++。我确实安装了g++。您是否尝试过
cabal安装-v hmatrix
以查看失败的步骤?这可能有助于缩小问题的范围。@JohnL有效的。。。我试图按照下面的建议安装nix,但C编译器无法创建可执行文件,这给我带来了麻烦。在我的道路上是一个GCC4.8版本,我刚才正在玩。因此,在第一个路径上有GCC4.2的终端中,我尝试了
cabal安装-v hmatrix
,它成功了。@usmcs很高兴您修复了它。在检查gcc版本之前,我已经猜了很长时间了……我确实使用
端口安装gsl-devel+universal
安装了-dev版本。我将检查libgsl0 dev的位置。我的系统上没有libgsl0 dev。这与libgsl有什么不同?嗯。您有任何格式为
libgsl?-dev
的文件名吗?我不知道
libgsl0 dev
中的
0
是否重要,但我认为
-dev
位很重要。通常,您需要库的
-dev
版本来对其进行任何开发。可能是gsl-devel的安装出了问题。我最终没有使用nix,但当我尝试构建它时,我发现它与我使用的gcc版本不一致。这肯定会让我找到解决办法。谢谢@美国海军陆战队很高兴这有帮助。