4.7.1 mysql_config — Display Options for Compiling Clients编译客户端的显示选项

mysql_config provides you with useful information for compiling your MySQL client and connecting it to MySQL. It is a shell script, so it is available only on Unix and Unix-like systems.mysql_config为您提供了编译mysql客户端并将其连接到mysql的有用信息。它是一个shell脚本,因此仅在Unix和类Unix系统上可用。

Note注意

pkg-config can be used as an alternative to mysql_config for obtaining information such as compiler flags or link libraries required to compile MySQL applications. pkg-config可以用作mysql_config的替代品,用于获取编译mysql应用程序所需的编译器标志或链接库等信息。For more information, see Building C API Client Programs Using pkg-config.有关更多信息,请参阅使用pkg-config构建C API客户端程序

mysql_config supports the following options.

If you invoke mysql_config with no options, it displays a list of all options that it supports, and their values:如果你在没有选项的情况下调用mysql_config,它会显示它支持的所有选项及其值的列表:

shell> mysql_config
Usage: /usr/local/mysql/bin/mysql_config [options]
Options:
  --cflags         [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro]
  --cxxflags       [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro]
  --include        [-I/usr/local/mysql/include/mysql]
  --libs           [-L/usr/local/mysql/lib/mysql -lmysqlclient
                    -lpthread -lm -lrt -lssl -lcrypto -ldl]
  --libs_r         [-L/usr/local/mysql/lib/mysql -lmysqlclient_r
                    -lpthread -lm -lrt -lssl -lcrypto -ldl]
  --plugindir      [/usr/local/mysql/lib/plugin]
  --socket         [/tmp/mysql.sock]
  --port           [3306]
  --version        [5.8.0-m17]
  --variable=VAR   VAR is one of:
          pkgincludedir [/usr/local/mysql/include]
          pkglibdir     [/usr/local/mysql/lib]
          plugindir     [/usr/local/mysql/lib/plugin]

You can use mysql_config within a command line using backticks to include the output that it produces for particular options. 您可以在命令行中使用mysql_config,使用回溯来包含它为特定选项生成的输出。For example, to compile and link a MySQL client program, use mysql_config as follows:例如,要编译和链接MySQL客户端程序,请按如下方式使用mysql_config

gcc -c `mysql_config --cflags` progname.c
gcc -o progname progname.o `mysql_config --libs`