简体   繁体   English

ghc编译错误,但runghc可以工作

[英]ghc compile error but runghc works

UPDATE SOLVED 已解决的更新

I updated to Haskell Platform 2011.2.0.1 and GHC 7.0.3 and now it works!! 我更新了到Haskell Platform 2011.2.0.1和GHC 7.0.3,现在它可以工作了!!

I have the following haskell file named "webscrap2.hs". 我有以下名为“ webscrap2.hs”的haskell文件。 I can execute "runghc webscrap2.hs" and it works fine. 我可以执行“ runghc webscrap2.hs”,它可以正常工作。 However when I compile the file I get an error. 但是,当我编译文件时,出现错误。

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 ghc-版本

The Glorious Glasgow Haskell Compilation System, version 6.12.3

ghc -o webscrap2 webscrap2.hs 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? 任何指针可能是什么问题?

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

假设你已经运行cabal install tagsoup那么它是一个小问题--make

 ghc -o webscrap2 webscrap2.hs --make

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM