I tried to install unixODBC and MyODBC to enable ODBC functionality from OpenOffice with my already installed MySQL database server. Unfortunately, every time I tried to access an ODBC data source from OpenOffice, the application crashed with an unrecoverable error.

I installed MyODBC and unixODBC from source packages, but OpenOffice was a binary installation, as was MySQL (as it came with Slackware Linux 8.1). After narrowing down the cause to a possible problem in libmysqlclient.so, I decided to download the MySQL source and rebuild and reinstall. The problem remained.

Eventually, I managed to trace the problem to a specific line in MySQL, specifically in libmysql/libmysql.c:

$ diff libmysql.c libmysql.c-orig 
1053,1054c1053
< /*VTT if ((serv_ptr = getservbyname("mysql", "tcp")))*/
< /*VTT*/ if(0)
---
> if ((serv_ptr = getservbyname("mysql", "tcp")))

That is, an innocent call to getservbyname fails for some reason, probably a bug in the libraries distributed with Slackware. (The same failure cannot be reproduced in a standalone test, nor does it occur with other ODBC client tools.) Since the call to getservbyname is really just convenience functionality, it can safely be commented out, and OpenOffice works fine afterwards.