You can call the mysql_library_init() function to initialize the C API library.
Syntax
int
mysql_library_init(int argc,
char **argv,
char **groups)
The argc and argv arguments are similar to the arguments of main(). For applications of normal (non-built-in) clients, if the server does not have command-line arguments, argc may be 0, and the call is made usually in the mysql_library_init(0, NULL, NULL) format.
The groups argument is a string array consisting of groups of options to be read from the option file. Make sure that the last entry in the array is NULL. If the value of the groups argument is NULL, the [server] and [embedded] groups are used by default.
Return values
0 is returned for an execution success, and a non-zero value is returned for errors.
Notes
Before you call other functions, you must call this function to initialize the C API library.
In a non-multithreaded environment, the call to mysql_library_init() can be omitted, because mysql_init() will automatically call it as necessary. However, mysql_library_init() is not thread-safe in a multithreaded environment. Therefore, mysql_init() that calls mysql_library_init() is also not thread-safe. You must call mysql_library_init() before generating any threads, or use a mutex to protect the call, no matter whether you call mysql_library_init() directly or indirectly through mysql_init(). Perform this operation prior to any other client library call.