I upgraded from Debian Jessie to Debian Stretch, and now found out that MariaDB has replaced MySQL, which is fine.
Luckily, on C++, the MariaDB client is still accessible with
#include <mysql/mysql.h>
However, the linking is different. I used to link with -lmysqlclient
, and now I have to link to -lmariadbclient
.
My program has to work on both. So my question is: Is there a way to check whether MySQL is available, and if not, link to MariaDB?
I'm using qmake and cmake in the relevant projects. Please advise.
For cmake you could simply use:
find_library( MYSQL_LIBRARY
NAMES "mysqlclient" "mysqlclient_r"
PATHS "/lib/mysql"
"/lib64/mysql"
"/usr/lib/mysql"
"/usr/lib64/mysql"
"/usr/local/lib/mysql"
"/usr/local/lib64/mysql"
"/usr/mysql/lib/mysql"
"/usr/mysql/lib64/mysql" )
And then check it with:
if(MYSQL_LIBRARY) {
...
}
Like the examples from github: FindMYSQL(RenatoUtsch) or FindMySQL(mloskot).
For qmake the only thing i found is to check for typical locations like this:
!exists("/foo/bar/baz.so"):!exists("/hello/world/baz.so"):...: message("...")