ghc 编译错误但 runghc 有效
更新已解决
我更新到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能想尝试更新 GHC 和您正在使用的软件包,看看是否有帮助。
You might want to try updating your GHC and the packages you are using, see if that helps.
假设您已经运行了
cabal install tagoup
,那么这只是--make
的小问题:Assuming you have run
cabal install tagsoup
then it is a small matter of--make
: