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!!
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 Tex开发者_如何学Ct.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?
You might want to try updating your GHC and the packages you are using, see if that helps.
Assuming you have run cabal install tagsoup
then it is a small matter of --make
:
ghc -o webscrap2 webscrap2.hs --make
精彩评论