使用 GHC,在用户空间安装带有 GMP 的 cabal

发布于 2024-08-27 11:42:26 字数 658 浏览 4 评论 0原文

我一直在尝试在未安装 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-09-03 11:42:26

基本上,你的 ghc 还没有工作。是的,它可以编译东西,但它不能链接程序,因为它需要将它们链接到 gmp。

我们可以做的是编辑一些核心包,例如 rts 包,以便 ghc 始终使用正确的 -L 标志:

ghc-pkg describe rts > rts.pkg
vi rts.pkg                      # add the gmp dir to the `library-dirs` field
sudo ghc-pkg update rts.pkg

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:

ghc-pkg describe rts > rts.pkg
vi rts.pkg                      # add the gmp dir to the `library-dirs` field
sudo ghc-pkg update rts.pkg
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文