7

我在 OS X Lion 上构建hmatrix 库时遇到问题。查看 .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 的 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\"]")
 ]
4

2 回答 2

2

As an alternative to mac-ports you can use the nix package manager for mac. It does a pretty good job of taking care of the c dependancies for for the libraries available through it. In general I have been more happy with it then any other package manager on mac.

Unfortunately mac(darwin) unlike for linux does not have as many binaries available through nix so installing ghc often means waiting for it to compile.

The commands to install ghc and hmatrix after installation of nix are:

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

All of the needed dependencies will be taken care of for you.

I just tried it on my macbook pro and hmatrix seems to be working correctly in ghci after trying commands from the first few pages of the tutorial.

于 2013-05-01T03:45:35.257 回答
1

我不是 Mac 用户,但听起来你确实没有安装“-dev”版本。gsl-devel对于 Mac,我怀疑您除了需要安装gsl. 如果问题仍然存在,请验证libgsl0-dev您的库路径是否存在。

于 2013-04-30T17:14:22.630 回答