[Haskell-beginners] Problems with Database

Gary Klindt gary.klindt at uni-konstanz.de
Fri Aug 5 00:45:27 CEST 2011


Hi all,

I tried using a database via haskell. The following simple test program 
could not be compiled via 'ghc Main.hs'. The output of ghc is:

Main.o: In function `s1pB_info':
(.text+0x6e): undefined reference to 
`HDBCzmpostgresqlzm2zi2zi3zi3_DatabaseziHDBCziPostgreSQLziConnectionImpl_zdfIConnectionConnection_closure'
Main.o: In function `s1qt_info':
(.text+0x169): undefined reference to 
`HDBCzmpostgresqlzm2zi2zi3zi3_DatabaseziHDBCziPostgreSQLziConnection_connectPostgreSQL_closure'
Main.o: In function `s1qt_info':
(.text+0x279): undefined reference to 
`__stginit_HDBCzm2zi2zi7zi0_DatabaseziHDBC_'
Main.o: In function `s1qt_info':
(.text+0x283): undefined reference to 
`__stginit_HDBCzmpostgresqlzm2zi2zi3zi3_DatabaseziHDBCziPostgreSQL_'
Main.o: In function `s1pB_info':
(.text+0x76): undefined reference to 
`HDBCzm2zi2zi7zi0_DatabaseziHDBCziTypes_disconnect_info'
Main.o: In function `s1pC_srt':
(.data+0x4): undefined reference to 
`HDBCzmpostgresqlzm2zi2zi3zi3_DatabaseziHDBCziPostgreSQLziConnectionImpl_zdfIConnectionConnection_closure'
Main.o: In function `s1qt_srt':
(.data+0x14): undefined reference to 
`HDBCzmpostgresqlzm2zi2zi3zi3_DatabaseziHDBCziPostgreSQLziConnection_connectPostgreSQL_closure'
collect2: ld returned 1 exit status

Is this a bug? Or do I need to modify the configuration of my system?

If I load that module into ghci (':l Main') the compilation succeeds.

% ghc --version: 'The Glorious Glasgow Haskell Compilation System, 
version 6.12.1'
% psql --version: 'psql (PostgreSQL) 8.4.8   contains support for 
command-line editing'

I also wanted to try out MySQL. I stranded much earlier:
% cabal install database-hdbc-mysql: There is no such package, but 
shouldn't there be one?


module Main where
import Database.HDBC
import Database.HDBC.PostgreSQL(connectPostgreSQL)

main :: IO ()
main = do
     c <- connectPostgreSQL "host=localhost dbname=haskell user=gary 
password=wasauchimmer"
     disconnect c
     return ()

I would be glad about help!
Greets
Gary



More information about the Beginners mailing list