当交叉编译haskell代码时,如何安装依赖项?
我已经成功地创建了一个ghc交叉编译器,它允许我从我的x64 linux机器中编译armv6h(我??的case中的raspberry pi)的haskell代码.
我已经成功地在树莓上运行了一个你好世界的节目. 不,我想建立我的真正的应用程序,它有很多依赖于其他haskell模块. cabal install dependenciy1 depenency2 ... 我知道我可以使自己的程序一个cabal项目自动化这一步.但这不是重点. 当我尝试使用交叉编译器 arm-unknown-linux-gnueabi-ghc --make myapp.hs 它告诉我关于它找不到的模块.当然,他们没有安装! 我读了https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling cabal --with-ghc=arm-unknown-linux-gnueabi-ghc --with-ghc-pkg=arm-unknown-linux-gnueabi-ghc-pkg --with-ld=arm-unknown-linux-gnueabi-ld install random 随机是我在这里安装的依赖.我收到以下错误: Resolving dependencies... Configuring random-1.0.1.3... Failed to install random-1.0.1.3 Last 10 lines of the build log ( /home/daniel/.cabal/logs/random-1.0.1.3.log ): /home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804: /home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804: cannot execute binary file cabal: Error: some packages failed to install: random-1.0.1.3 failed during the configure step. The exception was: ExitFailure 126 当我做 file /home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804 我得到 /home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804: ELF 32-bit LSB executable,ARM,EABI5 version 1 (SYSV),dynamically linked (uses shared libs),for GNU/Linux 3.10.2,not stripped 难怪它无法执行.它是为arm编译的. 我在这里遗漏了什么吗?
要了解这个错误,你需要知道cabal如何在内部安装.实质上,它将执行以下步骤:
>下载并解压缩源代码 现在的问题是,cabal安装使用–with-ghc给出的GHC也适用于步骤2,但由该步骤生成的可执行文件必须在主机系统上运行! 解决办法是手动执行这些步骤,这意味着您有完全的控制权.首先,得到来源: $cabal get random Downloading random-1.0.1.3... Unpacking to random-1.0.1.3/ $cd random-1.0.1.3 然后编译Setup.hs,使用主机ghc: $ghc ./Setup.hs -o setup 最后,配置,构建和安装.根据@Yuras在评论中的建议,我们还添加了运行hsc2hs的-x选项: $./setup configure ----with-ghc=arm-unknown-linux-gnueabi-ghc --with-ghc-pkg=arm-unknown-linux-gnueabi-ghc-pkg --with-ld=arm-unknown-linux-gnueabi-ld --hsc2hs-options=-x $./setup build && ./setup install 已经有一个关于这个的问题:https://github.com/haskell/cabal/issues/2085 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |