致命错误:google / protobuf / port_def.inc:没有这样的文件或目录#include <google / protobuf / port_def.inc>

时间:2019-07-03 14:08:35

标签: c++ windows tensorflow g++ protobuf-c

我有窗户。我想使用库tensorflow创建一个C ++ op。通过该网站https://www.tensorflow.org/guide/extend/op#compile_the_op_using_your_system_compiler_tensorflow_binary_installation,我了解我应该遵循以下条件:

TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
g++ -std=c++11 -shared zero_out.cc -o zero_out.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2

我做到了。但是我遇到下一个问题:

In file included from C:\Python\Python37\lib\site-packages\tensorflow\include/tensorflow/core/framework/op_def_builder.h:24,
                 from C:\Python\Python37\lib\site-packages\tensorflow\include/tensorflow/core/framework/op.h:23,
                 from zero_out.cc:4:
C:\Python\Python37\lib\site-packages\tensorflow\include/tensorflow/core/framework/op_def.pb.h:10:10: fatal error: google/protobuf/port_def.inc: No such file or directory
 #include google/protobuf/port_def.inc
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

我不知道如何解决此问题。如果您能帮助我解决这个问题,我将不胜感激

1 个答案:

答案 0 :(得分:0)

我认为您现在可能已经解决了该问题,但仅供其他参考,以发布一种可能的解决方案。找到tensorflow包含目录路径,并在编译代码时包含它。您可以手动检查头文件(在您的情况下为丢失)是否包含在包含路径中。

I/WM-WorkerWrapper: Work [ id=bc01ce9a-a29b-4810-86f8-d92f4810ef6d, tags={ com.microsoft.omadm.apppolicy.taskqueue.MAMTaskWorker, CHECKIN_TASK, _periodic, forcompliance_false, MAMServiceCheckinTask, com.kpmg.mcrm, User1949000933, force_false } ] was cancelled
java.util.concurrent.CancellationException: Task was cancelled.
    at androidx.work.impl.utils.futures.AbstractFuture.cancellationExceptionWithCause(AbstractFuture.java:1184)
    at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:514)
    at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
    at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:284)
    at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)

并修改您的编译命令以包含tf_include_dir即

tf_include_dir=($(python -c "import tensorflow as tf; print(tf.sysconfig.get_include())"))