mysql_config provides you with useful information how to compile your MySQL client and connect it to MySQL.
mysql_config supports the following options:
--cflags | Compiler flags to find include files and critical ccompiler flags and defines used when compiling the libmysqlclient library. |
--include | Compiler options to find MySQL include files. (Normally one would use --cflags instead of this) |
--libs | Libraries and options required to link with the MySQL client library. |
--libs_r | Libraries and options required to link with the thread-safe MySQL client library. |
--socket | The default socket name, defined when configuring MySQL. |
--port | The default port number, defined when configuring MySQL. |
--version | Version number and version for the MySQL distribution. |
--libmysqld-libs or --embedded | Libraries and options required to link with the MySQL embedded server. |
If you execute mysql_config without any options it will print all options it supports plus the value of all options:
shell> mysql_config Usage: /usr/local/mysql/bin/mysql_config [OPTIONS] Options: --cflags [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro] --include [-I/usr/local/mysql/include/mysql] --libs [-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -lssl -lcrypto] --libs_r [-L/usr/local/mysql/lib/mysql -lmysqlclient_r -lpthread -lz -lcrypt -lnsl -lm -lpthread] --socket [/tmp/mysql.sock] --port [3306] --version [4.0.16] --libmysqld-libs [-L/usr/local/mysql/lib/mysql -lmysqld -lpthread -lz -lcrypt -lnsl -lm -lpthread -lrt]
You can use this to compile a MySQL client by as follows:
CFG=/usr/local/mysql/bin/mysql_config sh -c "gcc -o progname `$CFG --cflags` progname.c `$CFG --libs`"