使用 GHC,在用户空间安装带有 GMP 的 cabal
我一直在尝试在未安装 GNU 多精度包 (GMP) 的系统上的用户空间中安装 Haskell Platform 和安装在 Linux 上的 cabal-install 。
我设法通过设置 LB_LIBRARY_PATH 指向我安装 GMP 的 lib 目录来安装 GHC-6.12.1 并让 GHCi 正常工作,但在下一步中遇到了问题,得到了 cabal -install 即可工作。它一直尝试(静态)链接到 GMP。
这会失败,因为 GMP 未安装在系统中,并且 ld 不知道在哪里可以找到库,并且没有环境变量(据我所知)可以告诉 ld 在哪里找到用户安装的 GMP,并且(显然)无法告诉配置 Cabal 提供相关的 -L
标志。
经过多次毫无结果的搜索和黑客尝试后,我想到了一个极其简单的想法,即安装我自己的 ld
shell 脚本,该脚本使用适当的 -L
调用系统 ld
代码> 标志。
当然,这是 shell 脚本 101:
#!/bin/sh
/usr/bin/ld -L$HOME/gnu/lib "$@"
将此脚本安装在我的 PATH
上的 /usr/bin
之前的目录中,所有问题似乎都消失了。
I have been trying to install Haskell Platform and cabal-install
installed on Linux in user-space on a system that doesn't have the GNU Multi-Precision package (GMP) installed.
I managed to get GHC-6.12.1 installed and GHCi working by setting up LB_LIBRARY_PATH
to point at the lib directory where I installed GMP, but then ran into problems in the next step, getting cabal-install
to work. It kept trying to (statically) link to GMP.
This fails because the GMP is not installed in the system and ld
hasn't a clue where to find the libraries, and there is no environment variable (that I am aware of) that can tell ld where to find the user-installed GMP, and (apparently) no way of telling configuring Cabal to supply the relevant -L
flag.
After much fruitless searching and hacking attempts I hit on the absurdly simple idea of installing my own ld
shell script that invokes the system ld
with the appropriate -L
flag.
This is shell scripting 101, of course:
#!/bin/sh
/usr/bin/ld -L$HOME/gnu/lib "$@"
With this script installed in a directory on my PATH
ahead of /usr/bin
all the problems seem to have gone away.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,你的 ghc 还没有工作。是的,它可以编译东西,但它不能链接程序,因为它需要将它们链接到 gmp。
我们可以做的是编辑一些核心包,例如 rts 包,以便 ghc 始终使用正确的
-L
标志:Basically, your ghc is not working yet. Yes, it can compile things, but it cannot link programs because it needs to link them to gmp.
What we can do is to edit some core package, e.g. the rts package, so that ghc will always use the right
-L
flag: