Error compiling using Network module

Hello to all, I have recently began using ghc, in particular the network module and I'm having problems with it. The following code ilustrates my problem, is very simple all I try to do is connect to a socket in my local machine send a request and print the response. -- BEGIN CODE import IO import Network host = "127.0.0.1" port = PortNumber 631 request = "GET / HTTP/1.1\nHost: 127.0.0.1:631\n\n" main = withSocketsDo $ do h <- connectTo host port hSetBuffering h LineBuffering hPutStr h request getResponse h hClose h getResponse h = do b <- hIsEOF h if b == False then do line <- hGetChar h hFlush h putChar line getResponse h else putStrLn "End of Input" -- END CODE When I try to compile it using the command: ghc -o socketTest socketTest.hs The following error appears: socketTest.o(.text+0xe2): In function `r2dL_info': : undefined reference to `NetworkziSocket_zdfNumPortNumber_closure' socketTest.o(.text+0x7c1): In function `s2f8_info': : undefined reference to `Network_connectTo_closure' socketTest.o(.text+0x8c3): In function `Main_main_info': : undefined reference to `NetworkziSocket_withSocketsDo_closure' socketTest.o(.text+0x971): In function `__stginit_Main_': : undefined reference to `__stginit_Network_' socketTest.o(.data+0x20): In function `r2dN_closure': : undefined reference to `Network_PortNumber_static_info' socketTest.o(.rodata+0x10): In function `r2dL_srt': : undefined reference to `NetworkziSocket_zdfNumPortNumber_closure' socketTest.o(.rodata+0x74): In function `s2fJ_srt': : undefined reference to `Network_connectTo_closure' socketTest.o(.rodata+0x9c): In function `Main_main_srt': : undefined reference to `NetworkziSocket_withSocketsDo_closure' collect2: ld returned 1 exit status I'm using ghc-6.4.1 in Gentoo Linux 2005.0 running kernel 2.6.13 and gcc-3.3.6 I don't know if is an error in my code or in ghc. Any sugestions? Thanks for your help -- Jorge E. Guerra D. Departamento de Computación y Tecnología de la Información Universidad Simón Bolívar

Jorge Guerra wrote:
Hello to all,
I have recently began using ghc, in particular the network module and I'm having problems with it. The following code ilustrates my problem, is very simple all I try to do is connect to a socket in my local machine send a request and print the response.
[snip]
When I try to compile it using the command:
ghc -o socketTest socketTest.hs
Try adding the network package as well; $ ghc -o socketTest socketTest.hs -package network You might also find the command $ ghc --make -o socketTest socketTest.hs useful since it will add exposed packages for you. Cheers, Lennart Kolmodin
participants (2)
-
Jorge Guerra
-
Lennart Kolmodin