Re: [Vala] mysql bindings in genie
- From: Jan Hudec <bulb ucw cz>
- To: Phil Daintree <phil logicworks co nz>
- Cc: vala-list gnome org
- Subject: Re: [Vala] mysql bindings in genie
- Date: Sat, 11 Sep 2010 10:08:10 +0200
On Fri, Sep 10, 2010 at 21:03:44 +1200, Phil Daintree wrote:
# valac --pkg=mysql mysqltest.gs
/tmp/ccumEU4F.o: In function `_vala_main':
mysqltest.vala.c:(.text+0xb6): undefined reference to `mysql_init'
mysqltest.vala.c:(.text+0xca): undefined reference to `mysql_close'
mysqltest.vala.c:(.text+0x116): undefined reference to `mysql_real_connect'
mysqltest.vala.c:(.text+0x13e): undefined reference to `mysql_query'
mysqltest.vala.c:(.text+0x14c): undefined reference to `mysql_use_result'
mysqltest.vala.c:(.text+0x160): undefined reference to `mysql_free_result'
mysqltest.vala.c:(.text+0x178): undefined reference to `mysql_eof'
mysqltest.vala.c:(.text+0x1de): undefined reference to `mysql_fetch_row'
mysqltest.vala.c:(.text+0x27b): undefined reference to `mysql_close'
mysqltest.vala.c:(.text+0x293): undefined reference to `mysql_free_result'
collect2: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
libmysqlclient does not have a pkg-config file, right? So you have to pass
the relevant linker flags yourself. That would be '-X -lmysqlclient' IIRC.
Normally if you specify "--pkg=something" to valac, it will use
"something.vapi", but it will also ask pkg-config for compiler flags needed
to compile against "something" ("pkg-config --cflags --libs something").
Unfortunately mysql client library does not seem to come with appropriate
data file for pkg-config. Instead it seems to have mysql_config script, that
serves similar purpose, but valac is not able to call these custom scripts.
Therefore you have to specify the flags manually via -X. You have the headers
and libraries installed in default path, but you still need to specify at
least the library name.
The mysql.h file is under /usr/include/mysql together with all the
other mysql header files.
The header got included fine and the program compiled fine. The library is
what was missing, so the program failed to link.
--
Jan 'Bulb' Hudec <bulb ucw cz>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]