提问人:whatamess 提问时间:10/24/2023 更新时间:10/24/2023 访问量:28
使用 Fleet 库时出现编译错误
Compilation errors when using Fleet library
问:
我正在尝试将 Fleet 库用于一个项目。但是,当在任何项目文件夹(例如,这个文件夹)中运行时,我遇到了几个编译错误。make
下面是 Sorting 模型的示例输出:make
g++-10 Main.cpp -o main -O2 -std=c++20 -Wall -fdiagnostics-color=auto -Wimplicit-fallthrough -Wall -Wshadow -Wextra -Wextra-semi -Wpedantic -Wvla -Wnull-dereference -Wswitch-enum -Wno-unused-parameter -fvar-tracking-assignments -Wduplicated-cond -Wduplicated-branches -Wsuggest-override -march=native -ftemplate-backtrace-limit=0 -fstack-protector-strong --param max-inline-insns-recursive=100000 -fcoroutines -fno-non-call-exceptions -fwrapv -fexceptions -I../..//src/ -I../..//src/Inference -I../..//src/Hypotheses -I../..//src/VirtualMachine -I../..//src/VirtualMachine/Program/ -I../..//src/Statistics -I../..//src/Grammar -I../..//src/Grammar/Enumeration -I../..//src/Data -I../..//src/Containers -I../..//src/Threads -I../..//src/Dependencies -I../..//src/Inference/MCTS -I../..//src/Inference/MCMC -I../..//src/Hypotheses/GrammarHypotheses -I../..//src/Hypotheses/StochasticVariables -lm -pthread -I /usr/local/include/eigen3/
In file included from /usr/include/c++/10/atomic:41,
from ../..//src/strings.h:4,
from /usr/include/string.h:432,
from /usr/include/c++/10/cstring:42,
from /usr/include/eigen3/Eigen/Core:283,
from ../..//src/Dependencies/EigenLib.h:10,
from Main.cpp:3:
/usr/include/c++/10/bits/atomic_base.h:129:3: error: template with C linkage
129 | template<typename _Tp>
| ^~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/cmath:41,
from /usr/include/c++/10/random:38,
from ../..//src/Numerics.h:7,
from ../..//src/Dependencies/EigenLib.h:3,
from Main.cpp:3:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
28 | __BEGIN_DECLS
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/atomic:41,
from ../..//src/strings.h:4,
from /usr/include/string.h:432,
from /usr/include/c++/10/cstring:42,
from /usr/include/eigen3/Eigen/Core:283,
from ../..//src/Dependencies/EigenLib.h:10,
from Main.cpp:3:
/usr/include/c++/10/bits/atomic_base.h:139:3: error: template with C linkage
139 | template<typename _IntTp>
| ^~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/cmath:41,
from /usr/include/c++/10/random:38,
from ../..//src/Numerics.h:7,
from ../..//src/Dependencies/EigenLib.h:3,
from Main.cpp:3:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
28 | __BEGIN_DECLS
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/atomic:41,
from ../..//src/strings.h:4,
from /usr/include/string.h:432,
from /usr/include/c++/10/cstring:42,
from /usr/include/eigen3/Eigen/Core:283,
from ../..//src/Dependencies/EigenLib.h:10,
from Main.cpp:3:
/usr/include/c++/10/bits/atomic_base.h:151:3: error: template with C linkage
151 | template<typename _Tp>
| ^~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/cmath:41,
from /usr/include/c++/10/random:38,
from ../..//src/Numerics.h:7,
from ../..//src/Dependencies/EigenLib.h:3,
from Main.cpp:3:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
28 | __BEGIN_DECLS
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/atomic:41,
from ../..//src/strings.h:4,
from /usr/include/string.h:432,
from /usr/include/c++/10/cstring:42,
from /usr/include/eigen3/Eigen/Core:283,
from ../..//src/Dependencies/EigenLib.h:10,
from Main.cpp:3:
/usr/include/c++/10/bits/atomic_base.h:154:3: error: template with C linkage
154 | template<typename _Tp>
| ^~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/cmath:41,
from /usr/include/c++/10/random:38,
from ../..//src/Numerics.h:7,
from ../..//src/Dependencies/EigenLib.h:3,
from Main.cpp:3:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
28 | __BEGIN_DECLS
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/atomic:41,
from ../..//src/strings.h:4,
from /usr/include/string.h:432,
from /usr/include/c++/10/cstring:42,
from /usr/include/eigen3/Eigen/Core:283,
from ../..//src/Dependencies/EigenLib.h:10,
from Main.cpp:3:
/usr/include/c++/10/bits/atomic_base.h:264:3: error: template with C linkage
264 | template<typename _ITp>
| ^~~~~~~~
etc.etc.
In file included from /usr/include/string.h:432,
from /usr/include/c++/10/cstring:42,
from /usr/include/eigen3/Eigen/Core:283,
from ../..//src/Dependencies/EigenLib.h:10,
from Main.cpp:3:
../..//src/strings.h:175:8: error: conflicting declaration of C function ‘size_t count(const string&, char)’
175 | size_t count(const std::string& str, const char x) {
| ^~~~~
../..//src/strings.h:153:8: note: previous declaration ‘size_t count(const string&, const string&)’
153 | size_t count(const std::string& str, const std::string& sub) {
| ^~~~~
../..//src/strings.h:224:6: error: conflicting declaration of C function ‘void check_alphabet(std::vector<std::__cxx11::basic_string<char> >, const string&)’
224 | void check_alphabet(std::vector<std::string> t, const std::string& a){
| ^~~~~~~~~~~~~~
../..//src/strings.h:215:6: note: previous declaration ‘void check_alphabet(const string&, const string&)’
215 | void check_alphabet(const std::string& s, const std::string& a) {
| ^~~~~~~~~~~~~~
Main.cpp:146:7: error: ‘void MyHypothesis::print(std::string)’ marked ‘override’, but does not override
146 | void print(std::string prefix="#\n") override {
| ^~~~~
Main.cpp: In member function ‘void MyHypothesis::print(std::string)’:
Main.cpp:159:10: error: ‘print’ is not a member of ‘MyHypothesis::Super’ {aka ‘StochasticLOTHypothesis<MyHypothesis, std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, MyGrammar, (& grammar)>’}
159 | Super::print(prefix);
| ^~~~~
make: *** [Makefile:9: all] Error 1
我在安装了 g++-10 的机器上运行它,因为 Fleet 需要 C++20 支持。我在 Makefile 中替换了 以获得正确的版本,因为默认情况下,在我的 Ubuntu 版本中指的是 v9。g++
g++-10
g++
如果有帮助,下面是以下输出:g++-10 -v
Using built-in specs.
COLLECT_GCC=g++-10
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-S4I5Pr/gcc-10-10.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-S4I5Pr/gcc-10-10.3.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04)
任何解决这些问题的见解或建议将不胜感激!
答: 暂无答案
评论
/usr/include/string.h:432
../..//src/strings.h:4