GHC 链接问题

发布于 2024-11-30 13:49:42 字数 1025 浏览 1 评论 0原文

我正在尝试编译以下代码。

import Data.List
import Data.Ord
import qualified Data.MemoCombinators as Memo

collatzLength :: Int -> Int
collatzLength = Memo.arrayRange (1, 1000000) collatzLength'
  where
    collatzLength' 1 = 1
    collatzLength' n | odd n  = 1 + collatzLength (3 * n + 1)
                     | even n = 1 + collatzLength (n `quot` 2)

main = print $ maximumBy (comparing fst) $ [(collatzLength n, n) | n <- [1..1000000]]

Haskell 编译器吐出:

euler14.o: In function `s1pw_info':
(.text+0x8dd): undefined reference to `__stginit_datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_'
euler14.o: In function `rfX_info':
(.text+0x35d): undefined reference to `datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_arrayRange_info'
euler14.o: In function `rfX_srt':
(.data+0x4c): undefined reference to `datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_arrayRange_closure'
collect2: ld returned 1 exit status

我尝试谷歌搜索,但无济于事。有什么地方可以查找这些错误吗?它们是什么意思?

I'm trying to compile the following code.

import Data.List
import Data.Ord
import qualified Data.MemoCombinators as Memo

collatzLength :: Int -> Int
collatzLength = Memo.arrayRange (1, 1000000) collatzLength'
  where
    collatzLength' 1 = 1
    collatzLength' n | odd n  = 1 + collatzLength (3 * n + 1)
                     | even n = 1 + collatzLength (n `quot` 2)

main = print $ maximumBy (comparing fst) $ [(collatzLength n, n) | n <- [1..1000000]]

The Haskell compiler spits out:

euler14.o: In function `s1pw_info':
(.text+0x8dd): undefined reference to `__stginit_datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_'
euler14.o: In function `rfX_info':
(.text+0x35d): undefined reference to `datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_arrayRange_info'
euler14.o: In function `rfX_srt':
(.data+0x4c): undefined reference to `datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_arrayRange_closure'
collect2: ld returned 1 exit status

I tried googling, but to no avail. Is there anywhere these errors can be looked up? What do they mean?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

愿与i 2024-12-07 13:49:42

您必须使用 --make 标志进行编译。

You gotta compile with the --make flag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文