NDB API applications must be linked against both the MySQL and
NDB
client libraries. The
NDB
client library also requires some
functions from the mystrings
library, so this
must be linked in as well.
The necessary linker flags for the MySQL client library are
returned by mysql_config
--libs
. For multithreaded
applications you should use the --libs_r
instead:
$ mysql_config --libs_r -L/usr/local/mysql-5.1/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib -lssl -lcrypto
Formerly, to link an NDB API application, it was necessary to
add -lndbclient
, -lmysys
, and
-lmystrings
to these options, in the order
shown, and adding all the required linker flags to the
LDFLAGS
variable looked something like this:
LDFLAGS="$LDFLAGS "`mysql_config --libs_r` LDFLAGS="$LDFLAGS -lndbclient -lmysys -lmystrings"
Beginning with MySQL 5.1.24-ndb-6.2.16 and MySQL
5.1.24-ndb-6.3.14, it is necessary only to add
-lndbclient
to LD_FLAGS
, as
shown here:
LDFLAGS="$LDFLAGS "`mysql_config --libs_r` LDFLAGS="$LDFLAGS -lndbclient"
(For more information about this change, see Bug#29791.)