将 ghci 与库一起堆叠
Stack ghci with library
我有一个与 Haskell 库捆绑(并从中调用)的 C++ 库。我使用的自定义构建具有 cabal
、Makefile
和 Setup.hs
文件,这些文件几乎与 here 中描述的相同。我也想使用 GHCi,所以我的 Makefile
除了静态 (.a
) 库之外还创建了一个动态 (.so
) 库。
Note: I think GHCi must use dynamic libraries; if I'm wrong about this then maybe there is an easier solution.
我可以通过将显式路径传递到 .so 文件来使 GHCi 在此环境中工作。 post 是关于如何使 stack ghci
工作的。这产生的主要错误是 cannot find libfoo.so
(由于在 cabal 文件中添加 extra-libraries: foo
)。使用 -v 显示堆栈未查看我在 Setup.hs 脚本中修改的 "extra-lib-dirs" 路径(possible bug bug). stack ghci
does look for libraries in the "extra-lib-dirs" that are specified in the cabal file. Unfortunately, due to a cabal bug,我无法指定 相对路径 extra-lib-dirs 的路径:它导致 cabal configure
和 stack build
都失败并出现相同的错误。
我不想在系统范围内安装我的 C++ 库(这将通过允许我在 extra-lib-dirs 中使用绝对路径来解决问题)。
具体问题:
- 我需要
.so
文件才能使用 GHCi 吗?
- 如何告诉
stack ghci
在 相对 路径中查找库的位置?
显示了一种更简洁的方法,可以将 C++ 库包含在 Haskell 库中,不需要使用 extra-libraries
或相对路径。这个想法是让 cabal 完成所有繁重的工作,而不是使用自定义构建类型。
stack ghci
有效(由于 GHC bug 而在构建顺序上有一些注意事项)。
我有一个与 Haskell 库捆绑(并从中调用)的 C++ 库。我使用的自定义构建具有 cabal
、Makefile
和 Setup.hs
文件,这些文件几乎与 here 中描述的相同。我也想使用 GHCi,所以我的 Makefile
除了静态 (.a
) 库之外还创建了一个动态 (.so
) 库。
Note: I think GHCi must use dynamic libraries; if I'm wrong about this then maybe there is an easier solution.
我可以通过将显式路径传递到 .so 文件来使 GHCi 在此环境中工作。 post 是关于如何使 stack ghci
工作的。这产生的主要错误是 cannot find libfoo.so
(由于在 cabal 文件中添加 extra-libraries: foo
)。使用 -v 显示堆栈未查看我在 Setup.hs 脚本中修改的 "extra-lib-dirs" 路径(possible bug bug). stack ghci
does look for libraries in the "extra-lib-dirs" that are specified in the cabal file. Unfortunately, due to a cabal bug,我无法指定 相对路径 extra-lib-dirs 的路径:它导致 cabal configure
和 stack build
都失败并出现相同的错误。
我不想在系统范围内安装我的 C++ 库(这将通过允许我在 extra-lib-dirs 中使用绝对路径来解决问题)。
具体问题:
- 我需要
.so
文件才能使用 GHCi 吗? - 如何告诉
stack ghci
在 相对 路径中查找库的位置?
extra-libraries
或相对路径。这个想法是让 cabal 完成所有繁重的工作,而不是使用自定义构建类型。
stack ghci
有效(由于 GHC bug 而在构建顺序上有一些注意事项)。