我正在尝试从源代码FlyWithLua编译一个应用程序,其中包括sol2库。
我是按照指示执行的,但是当我运行cmake --build ./build
时,我会得到以下错误:
In file included from /home/jon/src/FlyWithLua/src/FloatingWindows
/FLWIntegration.cpp:10:
/home/jon/src/FlyWithLua/src/third_party/sol2/./upstream/sol.hpp: In lambda function:
/home/jon/src/FlyWithLua/src/third_party/sol2/./upstream/sol.hpp:7194:59:
error: ‘numeric_limits’ is not a member of ‘std’
7194 | std::size_t space = (std::numeric_limits<std::size_t>::max)();
在这之后,在同一条线上还有其他几个错误,但我想如果我能解决这个问题,它们可能会消失。
有几个类似问题具有将以下内容添加到.hpp文件中的解决方案
#include <stdexcept>
#include <limits>
sol.hpp
文件包括以下导入:
#include <stddef.h>
#include <limits.h>
https://sol2.readthedocs.io/en/latest/errors.html提供了一些提示,说明为什么编译器可能无法识别这些内容,包括:
编译器错误/警告 当出了问题时,可能会发生无数的编译器错误。以下是有关使用这些类型的一些基本建议: 如果与std::index_sequence、类型特征和其他std::members相关的错误很多,那么很可能您还没有为编译器打开C++14开关。默认情况下,Visual 2015会打开这些功能,但是g++和clang++没有默认设置,您应该传递标记--std=c++1y或-std=c++14,或者类似于编译器。
src/CMakeList.txt文件有以下行:
集合(CMAKE_CXX_STANDARD 17)
我只是有点熟悉C/C++,这一切对我来说都很复杂,但我希望有一个容易识别的原因,并解决这个问题的人更熟练。
cat /etc/*-release
给出
DISTRIB_RELEASE=21.10
DISTRIB_CODENAME=impish
DISTRIB_DESCRIPTION="Ubuntu 21.10"
$ g++ --version
g++ (Ubuntu 11.2.0-7ubuntu2) 11.2.0
发布于 2022-02-28 15:04:35
/home/jon/src/FlyWithLua/src/third_party/sol2/./upstream/sol.hpp:7194:59:错误:‘numeric_limits’不是‘std’7194 std::size_t space =(std::numeric_limits::max)()的成员;
此错误消息意味着src/third_party/sol2/./upstream/sol.hpp
头使用std::numeric_limits
,但也意味着std::numeric_limits
尚未定义。最简单的解释是没有包含定义std::numeric_limits
的头。在这种情况下,解决方案是包含定义std::numeric_limits
的头。
sol.hpp文件包括以下导入: #包含 #包括
这证实了这个问题。这两个标头都没有定义std::numeric_limits
。
https://sol2.readthedocs.io/en/latest/errors.html提供了一些提示,说明为什么编译器可能无法识别这些内容,包括:
这些暗示可能适用于其他一些情况,但不适用于这个情况。std::numeric_limits
从一开始就成为C++标准的一部分,因此语言版本对它的存在没有影响。
结论:根据引用的错误消息,sol.hpp使用的是std::numeric_limits
,它是在标头<limits>
中定义的,但根据您的要求,它不包括该标头。如果是这样的话,那么这就是sol.hpp文件中的一个bug。正确的解决方案是在使用sol.hpp之前将<limits>
包含在该文件中,从而修复std::numeric_limits
文件。
https://stackoverflow.com/questions/71296302
复制相似问题