1

我正在尝试编译一个使用 Tensorflow 的 c++ 程序,但我遇到了一些问题。

基本思想是首先使用 bazel 生成一个动态库 .so 文件并将其传递给 g++。但似乎在那个阶段之前就出现了问题——我的程序首先在 tensorflow 中包含一个 .h 文件

#include "tensorflow/core/public/session.h"

我想我将正确的参数传递给 g++,因为它确实找到了头文件,但它在抱怨

../../tools/tensorflow/bazel-genfiles/tensorflow/core/framework/device_attributes.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is


#error This file was generated by a newer version of protoc which is

当我打开 device_attributes.pb.h 文件时,我看到这里产生了错误

11 #if GOOGLE_PROTOBUF_VERSION < 3002000
12 #error This file was generated by a newer version of protoc which is
13 #error incompatible with your Protocol Buffer headers. Please update
14 #error your headers.
15 #endif
16 #if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
17 #error This file was generated by an older version of protoc which is
18 #error incompatible with your Protocol Buffer headers. Please
19 #error regenerate this file with a newer version of protoc.
20 #endif

起初我以为是因为我机器上的协议太旧了;然后我尝试修改 PATH 以便它首先找到 protoc 的较新版本(3.2.0),但问题仍然存在;我什至在没有旧协议的另一台机器上尝试了同样的事情,但问题仍然存在。

我想知道是否有人以前遇到过类似的问题。谢谢。

4

1 回答 1

0

Oh I found the issue... It is because somewhere it includes a "google/protobuf/stubs/common.h" file, which it is supposed to use the one in the tensorflow package but somehow there must have been another file with the same name in my PATH, which is of a different version, and sets a different compiler variable.

于 2017-06-09T22:25:31.400 回答