
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@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@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@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

Chris Dornan
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
I have a possibly distantly related problem, a clunky solution, and would like to know if there's better advice. I tried to compile a statically linked binary of a program involving the X11 package: $ ghc --make tile.hs -optl-static -optl-pthread This gives undefined references because ghc tacks on -lX11, but not -lxcb, -lxcb-xlib, etc. $ ghc --make tile.hs -optl-static -optl-pthread -lXcb -lxcb-xlib ... This gives undefined references because (I think) the resulting link arguments aren't in the right order. So, I ended up doing $ ghc --make tile.hs -optl-static -optl-pthread -v Then taking the output and tacking on -lxcb, -lxcb-xlib, etc. in the right position, running it, and then it worked. So, perhaps you might want to look at the output with -v and seeing if everything looks the way it should.
participants (2)
-
Chris Dornan
-
Plareplane