[Haskell-cafe] external linking traumas

Chris Dornan chris at chrisdornan.com
Mon Oct 20 20:50:33 EDT 2008


Hi Folks,

I am battling Database.HSQL to get it to work on GHC-6.8.3 running Cygwin/XP
and I seem to have found a worthy opponent.

I have got the following to work:

	import Database.HSQL
	import Database.HSQL.MySQL

	main :: IO ()
	main = 
	     do c <- cnct
		tbs <- tables c
		putStr $ unlines $ "Tables:":["  "++tnm|tnm<-tbs]

	cnct :: IO Connection
	cnct = connect "host" "database" "user" "password"

To work on *ghci* that is, but I can't get it to work with *ghc*.

For ghci I use:

	ghci test.hs -llibmySQL

with libmySQL.dll copied into the same directory.

If I try the same with ghc:

	ghc test.hs  -package hsql-1.7 -package hsql-mysql-1.7 -L.
-llibmysql

with libmysql.lib copied into the same directory I get:

	C:\Program Files\Haskell\hsql-mysql-1.7\ghc-6.8.3/libHShsql-mysql-
1.7.a(MySQL.o)(.text+0x748):fake: undefined reference to `mysql_init at 4'
	C:\Program Files\Haskell\hsql-mysql-1.7\ghc-6.8.3/libHShsql-mysql-
1.7.a(MySQL.o)(.text+0x83f):fake: undefined reference to
`mysql_real_connect at 32'
	[...]
	C:\Program Files\Haskell\hsql-mysql-1.7\ghc-6.8.3/libHShsql-mysql-
1.7.a(MySQL.o)(.text+0x216c):fake: undefined reference to
`mysql_stmt_affected_rows at 4'
	collect2: ld returned 1 exit status

If I try substituting -llibmySQL (to select the dll) I get the same results.

GHC is clearly not resolving the links between Database.HSQL.MySQL and the
native libmysql.lib/libmySQL.dll in the way that ghci does with the dll.

I must be doing something silly.  If someone can tell me I would be
grateful.

I would also like to know what I need to do to package this up inside CABAL;
all my attempts so far have failed.

It seems that there has been no maintainer for HSQL for some time, which is
a shame, as folks seem to be repeatedly cracking their heads against these
problems and re-solving them.  I may be able to take on hsql and hsq-mysql
myself, but not the other backends.  Perhaps it is the prospect of
maintaining them all may be stopping folks from stepping forward.  (If it is
being maintained and I am just making a hash of it then please accept my
apologies.)

Cheers,

Chris



More information about the Haskell-Cafe mailing list