[Haskell-cafe] Re: external linking traumas

Plareplane plareplane at gmail.com
Tue Oct 21 03:36:15 EDT 2008


Chris Dornan <chris <at> chrisdornan.com> writes:

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




More information about the Haskell-Cafe mailing list