返回信息流在centos7的系统上编译TensorFlow的c++库,总是会遇到奇怪的报错。之前在Ubuntu系统上安装没啥问题。安装是按照TensorFlow官网上步骤来的
有没有大神可以给点指导,或者之前有经验的大神分享一下编译过程
报错如下:
```
ERROR: .../.cache/bazel/_bazel_sk103/46f66c8afcc04e6816b6d553e9e7afff/external/com_github_grpc_grpc/src/compiler/BUILD:80:1: Linking of rule '@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin' failed (Exit 1)
```
完整报错如下:```
ERROR: .../.cache/bazel/_bazel_sk103/46f66c8afcc04e6816b6d553e9e7afff/external/com_github_grpc_grpc/src/compiler/BUILD:80:1: Linking of rule '@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin' failed (Exit 1)
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function ProtoBufMethod::~ProtoBufMethod(): error: undefined reference to 'operator delete(void*, unsigned long)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function ProtoBufService::~ProtoBufService(): error: undefined reference to 'operator delete(void*, unsigned long)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function ProtoBufFile::~ProtoBufFile(): error: undefined reference to 'operator delete(void*, unsigned long)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function google::protobuf::io::StringOutputStream::~StringOutputStream(): error: undefined reference to 'operator delete(void*, unsigned long)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function grpc_cpp_generator::ClassName(google::protobuf::Descriptor const*, bool): error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function ProtoBufFile::package_parts() const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function CppGrpcGenerator::Generate(google::protobuf::FileDescriptor const*, std::string const&, google::protobuf::compiler::GeneratorContext*, std::string*) const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/_objs/grpc_cpp_plugin/cpp_plugin.o:cpp_plugin.cc:function CppGrpcGenerator::Generate(google::protobuf::FileDescriptor const*, std::string const&, google::protobuf::compiler::GeneratorContext*, std::string*) const: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)'
bazel-out/host/bin/external/com_google_protobuf/_objs/protobuf/dynamic_message.o:dynamic_message.cc:function google::protobuf::DynamicMessageFactory::GetPrototypeNoLock(google::protobuf::Descriptor const*) [clone .cold]: error: undefined reference to '__cxa_throw_bad_array_new_length'
bazel-out/host/bin/external/com_google_protobuf/_objs/protobuf/struct.pb.o:struct.pb.cc:function google::protobuf::Struct::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const [clone .cold]: error: undefined reference to '__cxa_throw_bad_array_new_length'
bazel-out/host/bin/external/com_google_protobuf/_objs/protobuf_lite/extension_set.o:extension_set.cc:function google::protobuf::internal::ExtensionSet::~ExtensionSet(): error: undefined reference to 'operator delete[](void*, unsigned long)'
bazel-out/host/bin/external/com_google_protobuf/_objs/protobuf_lite/extension_set.o:extension_set.cc:function google::protobuf::internal::ExtensionSet::GrowCapacity(unsigned long): error: undefined reference to 'operator delete[](void*, unsigned long)'
collect2: error: ld returned 1 exit status
Target //tensorflow:libtensorflow_cc.so failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: .../tensorflow/tensorflow-2.2.0/tensorflow/core/BUILD:1763:1 Linking of rule '@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin' failed (Exit 1)
INFO: Elapsed time: 108.309s, Critical Path: 51.10s
INFO: 1440 processes: 1440 local.
FAILED: Build did NOT complete successfully
```
这是一条镜像帖。来源:北邮人论坛 / cpp / #101254同步于 2021/9/27
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
【已解决】【求助】centos7编译libtensorflow
oooooome
2021/9/27镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
【 在 JudahGuo 的大作中提到: 】
: 看报错全是undefined references,感觉应该是少了某个库吧
他那个报错好像是说少了什么链接的规则,但是这个是用的TensorFlow的源码直接编译的,应该不会少了啥
【 在 nitroethane 的大作中提到: 】
: 会不会是gcc太旧了,换新的gcc试试。我看文档里经过测试的gcc大版本是7,centos 7默认版本是4.8
已经升级到9.1了,也试过7和8的版本的,都不行
感谢各位的回复,问题已经解决了
根据后面几条的报错信息,发现是跟标准库里的函数有关,便去网上搜了一下报错的原因,查到一个是说libstdc++.so的库的问题,可能是由于libstdc++.so的版本太低导致的。而libstdc++.so是gcc编译的时候用到的库,所以这个确实可能会有影响,因为TensorFlow编译要求至少7.3以上的gcc。
于是我去看了一下服务器上的libstdc++.so版本,确实是4.8.5对应的版本,于是将其更新到7.5.0的版本
问题解决