我在OS X Lion上构建hmatrix library时遇到了问题。查看.cabal文件,它需要gsl
库,所以我用macports安装它。 .a文件位于/ opt / local / lib中,而.h文件位于/ opt / local / include / gsl
正如建议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 :(得分:2)
作为mac-ports的替代方案,您可以使用mac的nix包管理器。它可以很好地处理通过它可用的库的cs dependancies。总的来说,我对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上试过它,并且在从tutorial的前几页尝试命令后,hmatrix似乎在ghci中正常工作。
答案 1 :(得分:1)
我不是一个mac人,但听起来你没有安装“-dev”版本。对于Mac,我怀疑除了gsl-devel
之外,您还需要安装gsl
。如果问题仍然存在,请验证您的库路径上是否有libgsl0-dev
。