I've installed GHC version 6.12.3 on CentOS 5.5 x86_64. I'm trying to run a very simple Haskell program as CGI following the guide at: http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell
My .hs file I'm trying to use looks like this: -------------------------------------------------------------- import Network.CGI import Text.XHtml page :: Html page = body << h1 << "Hello World!" cgiMain :: CGI CGIResult cgiMain = output $ renderHtml page main :: IO () main = runCGI $ handleErrors cgiMain -------------------------------------------------------------- If I compile it using dynamic linking I can run it from the command line, since the environment is correct: # ghc haskell_v2.hs --make -o haskell_v2.cgi Linking haskell_v2.cgi ... # ./haskell_v2.cgi Content-type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" ><body ><h1 >Hello World!</h1 ></body ></html > [root@vps-1040050-2953 haskellTest]# However I do of course want to run it through CGI on a webserver. I'm running lighttpd. If I try to run the file compiled above I get "500 - Internal Server Error", most likely since the enviroment is not correct for dynamic linked files: # ldd haskell_v2.cgi librt.so.1 => /lib64/librt.so.1 (0x00002aff22c25000) libutil.so.1 => /lib64/libutil.so.1 (0x00002aff22e2e000) libdl.so.2 => /lib64/libdl.so.2 (0x00002aff23031000) libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x00002aff23236000) libm.so.6 => /lib64/libm.so.6 (0x00002aff2346f000) libc.so.6 => /lib64/libc.so.6 (0x00002aff236f2000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00002aff23a4a000) /lib64/ld-linux-x86-64.so.2 (0x00002aff22a08000) # file haskell_v2.cgi haskell_v2.cgi: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped Hence I wanted to use static linking ( http://www.haskell.org/haskellwiki/Web/Literature/Static_linking ). However trying to compile using the "-optl-static" option fails: # ghc haskell_v2.hs --make -optl-static -fforce-recomp -o haskell_v2.cgi [1 of 1] Compiling Main ( haskell_v2.hs, haskell_v2.o ) Linking haskell_v2.cgi ... /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(HsNet.o): In function `hsnet_getaddrinfo': HsNet.c:(.text+0x11): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sAwu_info': (.text+0xd45d): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syh4_info': (.text+0x4364): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sygm_info': (.text+0x424f): warning: Using 'gethostent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syx3_info': (.text+0x5318): warning: Using 'sethostent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sxz5_info': (.text+0x12c6): warning: Using 'endhostent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syJY_info': (.text+0x605d): warning: Using 'getnetbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sycm_info': (.text+0x3e75): warning: Using 'getnetbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sybC_info': (.text+0x3de7): warning: Using 'getnetent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syyg_info': (.text+0x5458): warning: Using 'setnetent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sxz5_info': (.text+0x1296): warning: Using 'endnetent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syGE_info': (.text+0x5d42): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sylC_info': (.text+0x474f): warning: Using 'getprotoent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syvQ_info': (.text+0x51d8): warning: Using 'setprotoent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sxz5_info': (.text+0x12f6): warning: Using 'endprotoent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syEu_info': (.text+0x5a25): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syAp_info': (.text+0x55c4): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syCX_info': (.text+0x584c): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `syoz_info': (.text+0x49ef): warning: Using 'getservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sytu_info': (.text+0x5098): warning: Using 'setservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function `sxz5_info': (.text+0x1326): warning: Using 'endservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_create.o): In function `timer_create': (.text+0x124): undefined reference to `pthread_once' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_create.o): In function `timer_create': (.text+0x171): undefined reference to `pthread_attr_init' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_create.o): In function `timer_create': (.text+0x1b8): undefined reference to `pthread_attr_setdetachstate' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `__start_helper_thread': (.text+0x3f): undefined reference to `pthread_attr_init' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `__start_helper_thread': (.text+0x4c): undefined reference to `pthread_attr_setstacksize' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `__start_helper_thread': (.text+0x92): undefined reference to `pthread_create' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `__start_helper_thread': (.text+0xc6): undefined reference to `pthread_attr_destroy' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `__start_helper_thread': (.text+0xd4): undefined reference to `pthread_atfork' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `timer_helper_thread': (.text+0x1e1): undefined reference to `pthread_exit' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(timer_routines.o): In function `timer_helper_thread': (.text+0x21b): undefined reference to `pthread_create' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `init_mparams': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:2486:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:2490:0: undefined reference to `pthread_mutex_init' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:2493:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `internal_malloc_stats': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:2861:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:2888:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `internal_realloc': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:3777:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:3819:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `internal_memalign': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:3868:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:3915:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `ialloc': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:3998:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4052:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `dlmalloc': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4085:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4186:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `dlfree': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4211:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4285:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `dlmalloc_trim': /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4362:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/dlmalloc.c:4364:0: undefined reference to `pthread_mutex_unlock' /usr/haskell//lib/ghc-6.12.3/libHSffi.a(closures.o): In function `dlmmap': /home/ian/zz/ghc-6.12.3/libffi/build/src/closures.c:438:0: undefined reference to `pthread_mutex_lock' /home/ian/zz/ghc-6.12.3/libffi/build/src/closures.c:440:0: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2.o): In function `uw_init_context_1': (.text+0x1be5): undefined reference to `pthread_once' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__deregister_frame_info_bases': (.text+0x10bc): undefined reference to `pthread_mutex_lock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__deregister_frame_info_bases': (.text+0x10cd): undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_table_bases': (.text+0x117f): undefined reference to `pthread_mutex_lock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_bases': (.text+0x1238): undefined reference to `pthread_mutex_lock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `_Unwind_Find_FDE': (.text+0x14b6): undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `_Unwind_Find_FDE': (.text+0x14c7): undefined reference to `pthread_mutex_lock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_table_bases': (.text+0x119e): undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_bases': (.text+0x1257): undefined reference to `pthread_mutex_unlock' collect2: ld returned 1 exit status There are two main categories of error messages above: 1 : ...requires at runtime the shared libraries from the glibc version used for linking 2a : undefined reference to `pthread_....' 2b : undefined reference to `pthread_mutex_lock' I've had no luck in sorting out how to solve this and an quite new to both Linux and Haskell. I never managed to install (build from source failed) the entire Haskell Platform on CentOS 5.5, is that needed? Anyone has got any idea what might causing these errors? Regards, Frode
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe