我正在努力。我正在尝试使用以下说明编译 Marian:https://marian-nmt.github.io/docs/#installation。但失败了。
错误消息似乎表明代码与 c++20 之间存在冲突。但在仓库的所有
CMakeLists.txt
文件中,都有一行set (CMAKE_CXX_STANDARD 11)
。
这些是我遵循的步骤:
git clone https://github.com/marian-nmt/marian
mkdir marian/build
cd marian/build
cmake ..
make -j4
这是我得到的结果:
➜ make -j4
[ 1%] Built target 3rd_party_installs
[ 1%] Built target marian_version
[ 6%] Built target sentencepiece_train-static
[ 19%] Built target libyaml-cpp
[ 25%] Built target SQLiteCpp
[ 25%] Built target pathie-cpp
[ 32%] Built target zlib
[ 35%] Built target intgemm
[ 35%] Built target faiss
[ 53%] Built target sentencepiece-static
[ 55%] Built target spm_decode
[ 55%] Built target spm_normalize
[ 55%] Built target spm_encode
[ 55%] Building CXX object src/CMakeFiles/marian.dir/common/aliases.cpp.o
[ 55%] Building CXX object src/CMakeFiles/marian.dir/common/fastopt.cpp.o
[ 56%] Built target spm_train
[ 57%] Built target spm_export_vocab
[ 57%] Building CXX object src/CMakeFiles/marian.dir/common/utils.cpp.o
[ 58%] Building CXX object src/CMakeFiles/marian.dir/common/logging.cpp.o
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
from /data/tools/marian/src/common/logging.h:5,
from /data/tools/marian/src/common/definitions.h:3,
from /data/tools/marian/src/common/fastopt.h:3,
from /data/tools/marian/src/common/fastopt.cpp:1:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
138 | registry_t<Mutex>() {}
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
139 | registry_t<Mutex>(const registry_t<Mutex>&) = delete;
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
from /data/tools/marian/src/common/logging.h:5,
from /data/tools/marian/src/common/utils.cpp:2:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
138 | registry_t<Mutex>() {}
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
139 | registry_t<Mutex>(const registry_t<Mutex>&) = delete;
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
from /data/tools/marian/src/common/logging.h:5,
from /data/tools/marian/src/common/logging.cpp:1:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
138 | registry_t<Mutex>() {}
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
139 | registry_t<Mutex>(const registry_t<Mutex>&) = delete;
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
In file included from /data/tools/marian/src/3rd_party/spdlog/details/spdlog_impl.h:12,
from /data/tools/marian/src/3rd_party/spdlog/spdlog.h:139,
from /data/tools/marian/src/common/logging.h:5,
from /data/tools/marian/src/common/definitions.h:3,
from /data/tools/marian/src/common/cli_wrapper.h:6,
from /data/tools/marian/src/common/config_parser.h:4,
from /data/tools/marian/src/common/aliases.cpp:1:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
138 | registry_t<Mutex>() {}
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:138:22: note: remove the ‘< >’
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
139 | registry_t<Mutex>(const registry_t<Mutex>&) = delete;
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:93: src/CMakeFiles/marian.dir/common/fastopt.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:121: src/CMakeFiles/marian.dir/common/utils.cpp.o] Error 1
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:79: src/CMakeFiles/marian.dir/common/aliases.cpp.o] Error 1
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/marian.dir/build.make:135: src/CMakeFiles/marian.dir/common/logging.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:374: src/CMakeFiles/marian.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
请帮忙。
引入了您的构建正在跳闸的诊断,
Wtemplate-id-cdtor
与海湾合作委员会 14.1。这是一个警告,而不是一个错误,但您的构建将所有警告提升为
错误,因此它会破坏您的构建。
尽管您的构建在
-std=c++11
中指定了 src/3rd_party/spdlog/CMakeLists.txt
,但
生成失败,g++-14 发出 Wtemplate-id-cdtor
警告您代码 将是
在更新的标准 c++20(及更高版本)下是非法的。然后警告就变成错误了。
警告是编译选项导致的错误
-Werror
。该选项包含在列表中
编译选项 ALL_WARNINGS
,它是在顶层 marian/CMakeLists.txt
创建的
在第 227 行et seq:
# These are used in src/CMakeLists.txt on a per-target basis
list(APPEND ALL_WARNINGS -Wall; -Werror; -Wextra; -Wno-unused-result; -Wno-deprecated;
-Wno-pragmas; -Wno-unused-parameter; -Wno-unused-function;
-Wno-unused-value; -Wno-unknown-pragmas; -Wno-sign-compare;
-Wno-missing-field-initializers;)
然后作为
marian
中的 src/CMakeLists.txt
库目标的编译选项应用
第 133 行:
target_compile_options(marian PRIVATE ${ALL_WARNINGS})
因此,这些选项适用于编译失败的
src/CMakeFiles/marian.dir/common/logging.cpp
。
此故障是
marian
存储库中的一个错误,您应该向维护者报告,因为
似乎还没有报道过。 head 修订版 v1.12.0 比 GCC 14 早一年多。
在修复之前,您似乎有三个临时选项来完成构建。要么:
通过在每次出现时执行诊断建议所述操作,使代码对于 c++11 和 c++20 都合法:
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
139 | registry_t<Mutex>(const registry_t<Mutex>&) = delete;
| ^
/data/tools/marian/src/3rd_party/spdlog/details/registry.h:139:22: note: remove the ‘< >’
例如在这种情况下使其
registry_t(const registry_t<Mutex>&) = delete;
。
或者:
每次出现时本地禁用
-Wtemplate-id-cdtor
,例如:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtemplate-id-cdtor"
registry_t<Mutex>(const registry_t<Mutex>&) = delete;
#pragma GCC diagnostic pop
或者:
-Werror
中的 ALL_WARNINGS
列表中删除 marian/CMakeLists.txt
,以便 Wtemplate-id-cdtor
仍然只是警告。这可能会导致其他诊断从错误降级为警告(其默认状态)。我还没有测试任何这些选项,因为我需要麻烦地安装 CUDA。