【发布时间】:2021-09-27 21:15:34
【问题描述】:
我们正在使用 flatbuffer v1.3.0 并看到构建 flatc 编译器的错误。 flatbuffer 版本 v1.3.0 到 v1.12.1 的相同错误 2.0.0 版本构建成功
我们应该使用特定版本的 make 来构建 flatc 编译器吗?如果可以怎么办?
步骤
- git 克隆https://github.com/google/flatbuffers/tree/v1.3.0
- cd 平面缓冲区
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=发布 -成功
- make --错误
MacOS BigSur 版本 11.6 上安装的版本
$ cmake --version
cmake version 3.19.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/abcd/Documents/FlatBuffer/flatbuffers
$ make
Scanning dependencies of target flatc
[ 2%] Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.o
In file included from /Users/abcd/Documents/FlatBuffer/flatbuffers/src/idl_parser.cpp:28:
In file included from /Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/idl.h:25:
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1086:25: error: definition of implicit copy constructor for 'TableKeyComparator<reflection::Object>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
TableKeyComparator& operator= (const TableKeyComparator&);
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1100:27: note: in implicit copy constructor for 'flatbuffers::FlatBufferBuilder::TableKeyComparator<reflection::Object>' first required here
std::sort(v, v + len, TableKeyComparator<T>(buf_));
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1113:12: note: in instantiation of function template specialization 'flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables<reflection::Object>' requested here
return CreateVectorOfSortedTables(v->data(), v->size());
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/src/idl_parser.cpp:2008:35: note: in instantiation of function template specialization 'flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables<reflection::Object>' requested here```
【问题讨论】:
-
那么...问题是什么? SO是一个获得问题答案的地方,但这里没有问题。很明显,这个项目的旧版本中有一些不正确的代码被这个较新的编译器抱怨。这些问题似乎在项目的后续版本中得到了修复。
-
是的,最好始终使用最新版本/master进行测试..这些事情作为github问题可能会更好。
-
@MadScientist 我已经用一个问题更新了帖子。你说从 v1.3.0 到 v1.12.1 的所有版本都有问题吗?我已经发布了执行 make 命令后看到的错误
-
问题与make无关。 Make 只是一个用来运行编译器的工具。问题在于您尝试编译的代码和您正在使用的编译器(不是 make)的版本。大概是旧版本的编译器正确编译了这个旧代码。较新版本的编译器需要更改显然应用于较新版本的代码。我以前从未听说过 flatbuffers,所以我不知道哪些版本有或没有这些变化。
-
flatc 编译器已使用已预编译的 windows 可执行文件成功构建为 1.3.0 版。 github.com/google/flatbuffers/releases/tag/v1.3.0
标签: cmake gnu-make flatbuffers