c++ - 编译 Tensorflow 时 Protobuf 出错

标签 c++ makefile tensorflow

我目前正在尝试在非 bazel 项目中使用 Tensorflow 的共享库。

所以我使用以下方法构建了 .so 文件:

bazel build //tensorflow:libtensorflow.so

然后我按照描述加载依赖项here.

我在 Makefile 中添加了以下标志:

CFLAGS += -I/home/alpy/tensorflow/bazel-genfiles CFLAGS += -I/home/alpy/tensorflow/ CFLAGS += -I/home/alpy/tensorflow/tensorflow/contrib/makefile/downloads/eigen-latest/

LDFLAGS += -L../resources/

LDFLAGS += -ltensorflow.so

当我这样做时,我得到了这个相当奇怪的错误:

In file included from /home/alpy/tensorflow/tensorflow/core/public/session.h:22:0,
                 from ../src/conversion.h:14,
                 from ../src/conversion.cpp:1:
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:143:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
   PROTOBUF_DEPRECATED_ATTR void clear_version();
   ^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:144:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
   PROTOBUF_DEPRECATED_ATTR static const int kVersionFieldNumber = 3;
   ^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:145:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
   PROTOBUF_DEPRECATED_ATTR ::google::protobuf::int32 version() const;
   ^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:146:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
   PROTOBUF_DEPRECATED_ATTR void set_version(::google::protobuf::int32 value);
   ^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:273:37: error: no ‘void tensorflow::GraphDef::clear_version()’ member function declared in class ‘tensorflow::GraphDef’
 inline void GraphDef::clear_version() {
                                     ^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:276:54: error: no ‘google::protobuf::int32 tensorflow::GraphDef::version() const’ member function declared in class ‘tensorflow::GraphDef’
 inline ::google::protobuf::int32 GraphDef::version() const {
                                                      ^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:280:66: error: no ‘void tensorflow::GraphDef::set_version(google::protobuf::int32)’ member function declared in class ‘tensorflow::GraphDef’
 inline void GraphDef::set_version(::google::protobuf::int32 value) {

顺便说一句,我按照上面链接的页面上的描述加载了 protobuf。

最佳答案

我认为问题已按照此处所述解决:Google Groups discussion

只需添加一个新的 CFLAG:

-DPROTOBUF_DEPRECATED_ATTR=""

关于c++ - 编译 Tensorflow 时 Protobuf 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39251485/

相关文章:

gcc - 如何在 Mac 上安装 'make' 和 GCC

c++ - 如何根据条件对优先级队列使用不同的比较器

c++ - 重载运算符时可以使用标志吗?

c++ - 如何对(任意)POD C++ 结构施加词典顺序?

c - [Makefile] 添加颜色在 OS X 上不起作用

c++ - undefined reference to with inheritance, makefile 问题?

Java Tensorflow + Keras 等价于 model.predict()

java - 如何将 ByteBuffer 转换为 Bitmap Image?

python - 使用 MLP 和 Tensorflow 预测时间序列值

c++ - VS 代码 C++ : inaccurate system includePath errors (wchar. h,boost/lambda/lambda.hpp)