Need help linking to mysql libs

4 views
Skip to first unread message

matt...@workhorsy.org

unread,
May 30, 2009, 6:00:26 AM5/30/09
to LDC - the LLVM D compiler
I can't figure out how to link against mysql with ldc.

I have been using gdc to compile code like this. The db.a is a C
wrapper around some mysql functions. While the db.d is a D wrapper
around that:
gcc -g -c db.c -o db.o
ar rcs db.a db.o
gdc -g -fversion=Posix -o main main.d db.d db.a /usr/lib/tango-gdc/
libgtango.a -lz -lmysqlclient -L /usr/lib/mysql/

With ldc I am trying to do the same:
gcc -g -c db.c -o db.o
ar rcs db.a db.o
ldc -g -of main db.d db.a main.d -lmysqlclient -L /usr/lib/mysql/


Obviously that fails on the third steep, because it can't see the
mysql libs. I read the man page like 4 times, with no luck. So what is
the correct way to do this?

Christian Kamm

unread,
May 30, 2009, 6:41:20 AM5/30/09
to ldc...@googlegroups.com
On Saturday 30 May 2009 12:00 matt...@workhorsy.org wrote:
> With ldc I am trying to do the same:
> gcc -g -c db.c -o db.o
> ar rcs db.a db.o
> ldc -g -of main db.d db.a main.d -lmysqlclient -L /usr/lib/mysql/
>
>
> Obviously that fails on the third steep, because it can't see the
> mysql libs. I read the man page like 4 times, with no luck. So what is
> the correct way to do this?

Can you post the error message? If it fails to link, try using -v to see the
arguments passed to the linker.

Also, don't you get "Unknown command line argument: -lmysqlclient"? It should
be -L-l and -L-L, since these need to be passed on to the linker.

Regards,
Christian

signature.asc

matt...@workhorsy.org

unread,
Jun 19, 2009, 9:20:27 AM6/19/09
to LDC - the LLVM D compiler
Oh. Sorry for not replying for 2 weeks. I did not receive any email
from this group when you replied (even though I do from other google
groups). I just assumed that no one replied without checking.

Anyway, I figured it out that I can do this and it works:
ldc -g -of main db.d db.a main.d -L="-lmysqlclient"
Reply all
Reply to author
Forward
0 new messages