2016-08-29 62 views
1

我對Tensorflow有點問題。我必須將使用TF的代碼集成到已經存在的項目中(使用Makefile)。所以這就是我所做的。嘗試使用張量流的C++ API時出錯

我得到了從源頭上TF並安裝它描述on the TF site.

然後,我建立了一個共享庫:

bazel build //tensorflow:libtensorflow.so

這樣做後,我下面的行添加到Makefile:

CFLAGS += -I/home/alpy/tensorflow/bazel-genfiles 
CFLAGS += -I/home/alpy/tensorflow/ 
CFLAGS += -I/home/alpy/tensorflow/third_party/eigen3 

LDFLAGS += -L/home/alpy/tensorflow/bazel-bin/tensorflow 
LDFLAGS += -ltensorflow 

當我儘量做到,我得到這個奇妙的錯誤:link

編輯:我忘了解釋一些東西。我在Linux上,所以編譯器應該區分大小寫。我檢查了我的文件和TF文件,他們都似乎有#ifndef警衛。

編輯:作爲建議我,我直接添加到錯誤後:

In file included from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:0, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
[...] 

    from /home/alpy/tensorflow/tensorflow/core/public/session.h:23, 
       from ../src/conversion.h:11, 
       from ../src/detect_fast_C.cpp:43: 
/home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42: error: #include nested too deeply 
In file included from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:0, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
       from /home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1, 
[...] 
      from /home/alpy/tensorflow/tensorflow/core/framework/types.h:23, 
       from /home/alpy/tensorflow/tensorflow/core/framework/type_traits.h:22, 
       from /home/alpy/tensorflow/tensorflow/core/framework/allocator.h:25, 
       from /home/alpy/tensorflow/tensorflow/core/framework/tensor.h:21, 
       from /home/alpy/tensorflow/tensorflow/core/public/session.h:23, 
       from ../src/conversion.h:11, 
       from ../src/detect_fast_C.cpp:43: 
/home/alpy/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42: error: #include nested too deeply 

(這正好爲一段)

回答

0

我不認爲你應該添加那些-I包括

您可以查看bazel構建系統中的參考C++示例。

cc_binary。 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/cc/BUILD#L264

標誌: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tensorflow.bzl#L111

您可以運行巴澤勒建立與-s選項來查看發行構建目標的實際命令。

+0

當我避免-I包括我得到的錯誤,例如:ensorflow/core/public/session.h:沒有這樣的文件或目錄 –