8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 2 安装 MySQL / 2.8 从源安装 MySQL / 2.8.8 处理 MySQL 编译问题
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

2.8.8 处理 MySQL 编译问题2.8.8 Dealing with Problems Compiling MySQL

许多问题的解决方案涉及重新配置。如果要重新配置,请注意以下事项:The solution to many problems involves reconfiguring. If you do reconfigure, take note of the following:

  • 如果 CMake 在先前运行之后运行,则它可能会使用在先前调用期间收集的信息。此信息存储在 CMakeCache.txt 中。当 CMake 启动时,它会查找该文件并读取其内容(如果存在),并假设该信息仍然正确。当您重新配置时,该假设无效。If CMake is run after it has previously been run, it may use information that was gathered during its previous invocation. This information is stored in CMakeCache.txt. When CMake starts, it looks for that file and reads its contents if it exists, on the assumption that the information is still correct. That assumption is invalid when you reconfigure.

  • 每次运行 CMake 时,都必须再次运行 ma​​ke 进行重新编译。但是,您可能希望首先从以前的版本中删除旧的对象文件,因为它们是使用不同的配置选项进行编译的。Each time you run CMake, you must run make again to recompile. However, you may want to remove old object files from previous builds first because they were compiled using different configuration options.

要防止使用旧的对象文件或配置信息,请在重新运行 CMake 之前运行以下命令:To prevent old object files or configuration information from being used, run the following commands before re-running CMake:

在 Unix 上:On Unix:

$> make clean
$> rm CMakeCache.txt

在 Windows 上:On Windows:

$> devenv MySQL.sln /clean
$> del CMakeCache.txt

如果您在源代码树之外进行构建,请在重新运行 CMake 之前删除并重新创建构建目录。有关在源代码树之外构建的说明,请参阅如何使用 CMake 构建 MySQL 服务器。If you build outside of the source tree, remove and recreate your build directory before re-running CMake. For instructions on building outside of the source tree, see How to Build MySQL Server with CMake.

在某些系统上,由于系统包含文件的差异,可能会出现警告。以下列表描述了编译 MySQL 时最常出现的其他问题:On some systems, warnings may occur due to differences in system include files. The following list describes other problems that have been found to occur most often when compiling MySQL:

  • 要定义要使用的 C 和 C++ 编译器,您可以定义 CC 和 CXX 环境变量。例如: To define which C and C++ compilers to use, you can define the CC and CXX environment variables. For example:

    $> CC=gcc
    $> CXX=g++
    $> export CC CXX
    

    虽然这可以在命令行上完成,如刚才所示,但您可能更愿意在构建脚本中定义这些值,在这种情况下,不需要 export 命令。While this can be done on the command line, as just shown, you may prefer to define these values in a build script, in which case the export command is not needed.

    要指定您自己的 C 和 C++ 编译器标志,请使用 CMAKE_C_FLAGS 和 CMAKE_CXX_FLAGS CMake 选项。请参阅编译器标志。To specify your own C and C++ compiler flags, use the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS CMake options. See Compiler Flags.

    要查看您可能需要指定的标志,请调用mysql_config 与 --cflags 和 --cxxflags 选项。To see what flags you might need to specify, invoke mysql_config with the --cflags and --cxxflags options.

  • 查看编译阶段执行了哪些命令,使用CMake配置 MySQL 后,运行make VERBOSE=1,而不仅仅是make。To see what commands are executed during the compile stage, after using CMake to configure MySQL, run make VERBOSE=1 rather than just make.

  • 如果编译失败,请检查是否MYSQL_MAINTAINER_MODE 选项已启用。此模式会导致编译器警告变为错误,因此禁用它可能会使编译继续进行。If compilation fails, check whether the MYSQL_MAINTAINER_MODE option is enabled. This mode causes compiler warnings to become errors, so disabling it may enable compilation to proceed.

  • 如果编译失败并出现以下任何错误,则必须将 make 版本升级到 GNU make:If your compile fails with errors such as any of the following, you must upgrade your version of make to GNU make:

    make: Fatal error in reader: Makefile, line 18:
    Badly formed macro assignment
    

    或者:Or:

    make: file `Makefile' line 18: Must be a separator (:
    

    或者:Or:

    pthread.h: No such file or directory
    

    已知 Solaris 和 FreeBSD 存在麻烦make 程序。Solaris and FreeBSD are known to have troublesome make programs.

    GNU make 3.75 已知可以工作。GNU make 3.75 is known to work.

  • sql_yacc.cc 文件是从 sql_yacc.yy 生成的。通常,构建过程不需要创建sql_yacc.cc,因为 MySQL 附带了一个预先生成的副本。但是,如果您确实需要重新创建它,则可能会遇到以下错误:The sql_yacc.cc file is generated from sql_yacc.yy. Normally, the build process does not need to create sql_yacc.cc because MySQL comes with a pregenerated copy. However, if you do need to re-create it, you might encounter this error:

    "sql_yacc.yy", line xxx fatal: default action causes potential...
    

    这表明您的 yacc 版本有缺陷。您可能需要安装最新版本的 bison(yacc 的 GNU 版本)并使用它。This is a sign that your version of yacc is deficient. You probably need to install a recent version of bison (the GNU version of yacc) and use that instead.

    早于 1.75 的 bison 版本可能会报告此错误:Versions of bison older than 1.75 may report this error:

    sql_yacc.yy:#####: fatal error: maximum table size (32767) exceeded
    

    实际没有超过最大表大小;该错误是由旧版本 bison 中的错误引起的。The maximum table size is not actually exceeded; the error is caused by bugs in older versions of bison.

有关获取或更新工具的信息,请参阅第 2.8 节“从源代码安装 MySQL” 中的系统要求。For information about acquiring or updating tools, see the system requirements in Section 2.8, “Installing MySQL from Source”.