gpt4 book ai didi

c++ - fatal error : google/protobuf/port_def. inc : No such file or directory #include

转载 作者:行者123 更新时间:2023-12-03 06:51:11 25 4
gpt4 key购买 nike

我有 window 。我想使用库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.


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

最佳答案

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

tf_include_dir=($(python -c "import tensorflow as tf; print(tf.sysconfig.get_include())"))
并修改您的编译命令以包含tf_include_dir,即
g++ -std=c++11 -Itf_include_dir -shared zero_out.cc -o zero_out.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2

关于c++ - fatal error : google/protobuf/port_def. inc : No such file or directory #include <google/protobuf/port_def. inc>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56871990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com