undefined symbol: _ZTIN10tensorflow8OpKernelE

因为没有在g++中加入 -ltensorflow_framework

tf.sysconfig.get_link_flags()



把-L和-l的内容要对应写正确,这样编译才能通过

#!/usr/bin/env bash
nvcc=/usr/local/cuda-10.1/bin/nvcc
cudalib=/usr/local/cuda-10.1/lib64/
TF_INC=$(python3 -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB=$(python3 -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

g++ tf_interpolate.cpp -o tf_interpolate_so.so -std=c++11  -shared -fPIC -I $TF_INC  \
-I$TF_INC/external/nsync/public -L$TF_LIB -l:libtensorflow_framework.so.2 \
-lcudart -L $cudalib -O2 -D_GLIBCXX_USE_CXX11_ABI=0

你可能感兴趣的:(undefined symbol: _ZTIN10tensorflow8OpKernelE)