每日科技英文48: MySQL C API简介

96
随风而行之青衫磊落险峰行
2017.12.18 10:41* 字数 627

今日要点:

  1. MySQL C API的定义
  2. MySQL C API包含的内容
  3. 如何获取MySQL C API
  4. 什么是库(library)的解释
  5. windows版外带调试库

JDBC,ODBC,ADO,PDO....,每门语言都有各自的数据链接库。

如果写服务器的话,肯定是经常使用。

如果对于Mysql数据库来说,不管是JDBC, 还是ODBC,ADODB,PDO...最终终归会调用MySQL C API

所以MySQL C API是核心,很适合游戏服务器开发.

MySQL C API的定义:

The MySQL C API is a C-based API that client applications written in C can use to communicate with MySQL Server.

Client programs refer to C API header files at compile time and link to a C API library file at link time.

注: c/c++的库(或称为SDK包)包含两个必要的文件: 头文件以及链接库文件(包括静态链接库或动态链接库)

MySQL C API包含的内容:

The library comes in two versions, depending on how the application is intended to communicate with the server:

  • libmysqlclient: The client version of the library, used for applications that communicate over a network connection as a client of a standalone server process.

  • libmysqld: The embedded server version of the library, used for applications intended to include an embedded MySQL server within the application itself. The application communicates with its own private server instance.

Note
The libmysqld embedded server library is deprecated as of MySQL 5.7.19 and will be removed in MySQL 8.0.

注: 所有不要使用libmysqld服务端库!

如何获取MySQL C API:

There are two ways to obtain the C API header and library files required to build C API client programs:

  • Install a MySQL Server distribution. Server distributions include both libmysqlclient and libmysqld.

  • Install a Connector/C distribution. Connector/C distributions include only libmysqlclient. They do not include libmysqld.

注:在各个系统中标准方式安装MySQL后都带有 C AP库

什么是库(library)的解释:(静态库,动态库在不同操作系统上具有不同后缀名!!!)

The names of the library files to use when linking C API client applications depend on the library type and platform for which a distribution is built:

  • On Unix (and Unix-like) sytems, the static library is libmysqlclient.a. The dynamic library is libmysqlclient.so on most Unix systems and libmysqlclient.dylib on OS X.

For distributions that include embedded server libraries, the corresponding library names begin with libmysqld rather than libmysqlclient.

  • On Windows, the static library is mysqlclient.lib and the dynamic library is libmysql.dll. Windows distributions also include libmysql.lib, a static import library needed for using the dynamic library.

For distributions that include embedded server libraries, the corresponding library names are mysqlserver.lib, libmysqld.dll, and libmysqld.lib.

windows版外带调试库:

Windows distributions also include a set of debug libraries. These have the same names as the nondebug libraries, but are located in the lib/debug library. You must use the debug libraries when compiling clients built using the debug C runtime.

闲聊科技英语
Web note ad 1