我正在尝试从源代码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提供了一些提示,说明编译器可能无法识别这些内容的原因包括:
编译器错误/警告
当出现问题时,可能会出现无数编译器错误。以下是有关使用这些类型的一些基本建议:
If there are a myriad of errors relating to std::index_sequence, type traits, and other std:: members, it is likely you have not turned on your C++14 switch for your compiler. Visual Studio 2015 turns these on by default, but g++ and clang++ do not have them as defaults and you should pass the flag --std=c++1y or --std=c++14, or similar for your compiler.
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