MySQL ODBC connector: build and run tests

Январь 29th, 2013 | Posted by elenst in Pensieve | Testing

I spent some time on it, and I have a feeling I’ll have to do it again some day, so here it goes, assuming I’ve downloaded the source package of the connector (in my case it was 5.2.3) and either installed MySQL client library, or have a binaries and headers somewhere.

I will of course need different stuff for building, and in addition to that, unixODBC and unixODBC-devel (that’s how they are called for Fedora’s yum, I didn’t check others yet).

Then, if we have MySQL client library installed system-wide, I run
cmake -G "Unix Makefiles" -DWITH_UNIXODBC=1

And if we have it in a secret place, I run
cmake -G "Unix Makefiles" -DWITH_UNIXODBC=1 -DMYSQL_INCLUDE_DIR=<secret folder with MySQL/MariaDB include files> -DMYSQL_LIB_DIR=<secret folder with MySQL/MariaDB client libs>

Either way, just hope it will find all it needs. What it needs is another story: I’ve heard today that the connector is *supposed* to link statically, only it does not. It links dynamically if it can, which kind of supported by the connectors manual. It’s rather unfortunate, since it doesn’t seem to work all that well with the current MySQL client library:

$ ldd -r lib/ => (0x00007fffb49ff000) => /lib64/ (0x00007f5d1fdb8000) => /mysql-5.5.29/lib/ (0x00007f5d1f959000) => /lib64/ (0x00007f5d1f73d000) => /lib64/ (0x00007f5d1f442000) => /lib64/ (0x00007f5d1f22f000) => /lib64/ (0x00007f5d1f02b000) => /lib64/ (0x00007f5d1ec74000) => /lib64/ (0x00007f5d1ea6a000) => /lib64/ (0x00007f5d1e862000)
/lib64/ (0x000000353c200000)
undefined symbol: dynstr_append_os_quoted (lib/
undefined symbol: dynstr_append (lib/
undefined symbol: strfill (lib/
undefined symbol: init_dynamic_string (lib/
undefined symbol: dynstr_realloc (lib/
undefined symbol: dynstr_free (lib/
undefined symbol: dynstr_append_mem (lib/

Anyway, as long as it builds, we can run at least some tests from the test folder. There is even a perl script, but it doesn’t work for me, and neither does make test. I don’t know why, and for now I don’t care. I just need to get something run.

So, I set 2 variables just like the manual says:


The second one looks stupid, but I set it anyway. Whatever it takes.

In odbc.ini, I add


In odbcinst.ini, I add


Now, if I didn’t forget to start the server (importantly, on /tmp/mysql.sock, otherwise tests fail somewhere in the middle, even though they get the socket as a parameter), I can run

./test/my_basics elenstdsn root test /tmp/mysql.sock

I can’t say it works, it would be exaggeration, but at least it does something marginally sensible.

You can follow any responses to this entry through the RSS 2.0 Both comments and pings are currently closed.