Pregunta

I have downloaded the MySQL Connector/C driver from the official website, the version that I believe is supposed to be released next to 5.6.

I then obviously wanted to use the library so I wrote a small application. During linkage, I however got a strange linker errors saying it cannot find the functions mysql_library_init() and mysql_library_end().

When I use a command to check for the functions inside the library, nm /usr/lib64/mysql/libmysqlclient.a > ~/Desktop/symbols, I indeed cannot find the functions the linker mentioned.

The functions I do find however are mysql_server_init and mysql_server_end, which are according to the documentation, marked as deprecated. (There are more functions in there too)

What am I doing wrong? I am using version 6.1.2 of the driver.

¿Fue útil?

Solución

It seems like the problem is that the documentation is ahead of the code.

I am a DBA, not a C programmer, though I dabble in server internals. If the file include/mysql.h in the MySQL Server source files is any indication, the mysql_server_* functions are the ones you're looking for.

/*
  mysql_server_init/end need to be called when using libmysqld or
  libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
  you don't need to call it explicitely; but you need to call
  mysql_server_end() to free memory). The names are a bit misleading
  (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
  names which suit well whether you're using libmysqld or libmysqlclient. We
  intend to promote these aliases over the mysql_server* ones.
*/
#define mysql_library_init mysql_server_init
#define mysql_library_end mysql_server_end

"We intend to promote these aliases over the mysql_server* ones."

They promoted them in the documentation, apparently.

It looks like Bug #65887 was a report of the same problem, that they never really got around to doing anything with.

You might also find MariaDB's implementation of the C API "for MariaDB and MySQL" to be a viable and perhaps more agreeably-licensed alternative.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top