ghc 编译错误但 runghc 有效

发布于 2024-11-06 07:55:50 字数 1926 浏览 1 评论 0原文

更新已解决

我更新到 Haskell Platform 2011.2.0.1 和 GHC 7.0.3,现在它可以工作了!

我有以下名为“webscrap2.hs”的 haskell 文件。我可以执行“runghc webscrap2.hs”并且它工作正常。但是,当我编译该文件时,出现错误。

webscrap2.hs

import Text.HTML.TagSoup
import Network.Curl (curlGetString, URLString)

main :: IO ()
main = do html <- openURL "https://github.com/languages/Haskell/created"
          let links = linkify html
          print links

openURL :: URLString -> IO String
openURL target = fmap snd $ curlGetString target []

linkify :: String -> [String]
linkify l = [x | TagOpen "a" atts <- parseTags l, (_,x) <- atts]

ghc --version

The Glorious Glasgow Haskell Compilation System, version 6.12.3

ghc -o webscrap2 webscrap2.hs

webscrap2.o: In function `r17I_info':
(.text+0x1fe): undefined reference to `tagsoupzm0zi12_TextziHTMLziTagSoupziParser_parseTags_closure'
webscrap2.o: In function `r17I_info':
(.text+0x204): undefined reference to `tagsoupzm0zi12_TextziStringLike_zdfStringLikeZMZN_closure'
webscrap2.o: In function `s1eb_info':
(.text+0x6fc): undefined reference to `curlzm1zi3zi7_NetworkziCurl_curlGetString_closure'
webscrap2.o: In function `s1ed_info':
(.text+0x927): undefined reference to `__stginit_curlzm1zi3zi7_NetworkziCurl_'
webscrap2.o: In function `s1ed_info':
(.text+0x933): undefined reference to `__stginit_tagsoupzm0zi12_TextziHTMLziTagSoup_'
webscrap2.o: In function `r17I_srt':
(.data+0x90): undefined reference to `tagsoupzm0zi12_TextziHTMLziTagSoupziParser_parseTags_closure'
webscrap2.o: In function `r17I_srt':
(.data+0x98): undefined reference to `tagsoupzm0zi12_TextziStringLike_zdfStringLikeZMZN_closure'
webscrap2.o: In function `s1ed_srt':
(.data+0xf8): undefined reference to `curlzm1zi3zi7_NetworkziCurl_curlGetString_closure'
collect2: ld returned 1 exit status

有任何指示可能是什么问题吗?

UPDATE SOLVED

I updated to Haskell Platform 2011.2.0.1 and GHC 7.0.3 and now it works!!

I have the following haskell file named "webscrap2.hs". I can execute "runghc webscrap2.hs" and it works fine. However when I compile the file I get an error.

webscrap2.hs

import Text.HTML.TagSoup
import Network.Curl (curlGetString, URLString)

main :: IO ()
main = do html <- openURL "https://github.com/languages/Haskell/created"
          let links = linkify html
          print links

openURL :: URLString -> IO String
openURL target = fmap snd $ curlGetString target []

linkify :: String -> [String]
linkify l = [x | TagOpen "a" atts <- parseTags l, (_,x) <- atts]

ghc --version

The Glorious Glasgow Haskell Compilation System, version 6.12.3

ghc -o webscrap2 webscrap2.hs

webscrap2.o: In function `r17I_info':
(.text+0x1fe): undefined reference to `tagsoupzm0zi12_TextziHTMLziTagSoupziParser_parseTags_closure'
webscrap2.o: In function `r17I_info':
(.text+0x204): undefined reference to `tagsoupzm0zi12_TextziStringLike_zdfStringLikeZMZN_closure'
webscrap2.o: In function `s1eb_info':
(.text+0x6fc): undefined reference to `curlzm1zi3zi7_NetworkziCurl_curlGetString_closure'
webscrap2.o: In function `s1ed_info':
(.text+0x927): undefined reference to `__stginit_curlzm1zi3zi7_NetworkziCurl_'
webscrap2.o: In function `s1ed_info':
(.text+0x933): undefined reference to `__stginit_tagsoupzm0zi12_TextziHTMLziTagSoup_'
webscrap2.o: In function `r17I_srt':
(.data+0x90): undefined reference to `tagsoupzm0zi12_TextziHTMLziTagSoupziParser_parseTags_closure'
webscrap2.o: In function `r17I_srt':
(.data+0x98): undefined reference to `tagsoupzm0zi12_TextziStringLike_zdfStringLikeZMZN_closure'
webscrap2.o: In function `s1ed_srt':
(.data+0xf8): undefined reference to `curlzm1zi3zi7_NetworkziCurl_curlGetString_closure'
collect2: ld returned 1 exit status

Any pointers what the problem might be?

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

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

发布评论

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

评论(2

傾城如夢未必闌珊 2024-11-13 07:55:50

您可能想尝试更新 GHC 和您正在使用的软件包,看看是否有帮助。

You might want to try updating your GHC and the packages you are using, see if that helps.

清秋悲枫 2024-11-13 07:55:50

假设您已经运行了cabal install tagoup,那么这只是--make的小问题:

 ghc -o webscrap2 webscrap2.hs --make

Assuming you have run cabal install tagsoup then it is a small matter of --make:

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