tensorflow-windows-wheel
tensorflow-windows-wheel copied to clipboard
Cannot use static lib in my project. Missing protobuf related functions.
Hi,
I am trying to use your wonderful pre-built lib in my c++project.
It works well when using dynamic libs.
But I failed to link with tensorflow_static.lib
I tried the following version:
libtensorflow-cpu-windows-x86_64-1.8.0-avx2
libtensorflow-gpu-windows-x86_64-1.10.0-avx2cuda92cudnn72
My CMakeLists.txt are like follows.
set(TensorFlow_ROOT "E:/Libs/cpp/libtensorflow-cpu-windows-x86_64-1.8.0-avx2")
set(TensorFlow_INCLUDE_DIRS ${TensorFlow_ROOT}/include)
set(TensorFlow_LIBRARY_DIR ${TensorFlow_ROOT}/lib)
set(TensorFlow_LIBS tensorflow_static)
add_library(${TARGET_NAME} SHARED DeblurLib.cpp)
target_link_libraries(${TARGET_NAME} ${TensorFlow_LIBS} ${OpenCV_LIBS})
Then it produce so many undefined external symbols errors, most of related to protobuf. For example,
tensorflow_static.lib(tensor.pb_text.obj) : error LNK2019: 无法解析的外部符号 "public: void * __cdecl google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned __int64)" (?AllocateAligned@ArenaImpl@internal@protobuf@google@@QEAAPEAX_K@Z),该符号在函数 "public: class tensorflow::strings::Scanner & __cdecl tensorflow::strings::Scanner::Any(enum tensorflow::strings::Scanner::CharClass)" (?Any@Scanner@strings@tensorflow@@QEAAAEAV123@W4CharClass@123@@Z) 中被引用
tensorflow_static.lib(function.pb_text.obj) : error LNK2001: 无法解析的外部符号 "public: void * __cdecl google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned __int64)" (?AllocateAligned@ArenaImpl@internal@protobuf@google@@QEAAPEAX_K@Z)
...
Did I missed something?
I also tried to link another libprotobuf.lib
but the error remains.
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout b04e5cba356212e4e8c66c61bbe0c3a20537c5b9
連接這個版本的protobuf試試?
Thanks for your suggestions.
I tried with Protobuf 3.4.1, which is the same as b04e5cba356212e4e8c66c61bbe0c3a20537c5b9
.
I linked with libprotobuf.lib
and libprotoc.lib
, errors reduce to 204 from 249.
What else libs do I need, instead of tensorflow_static
please?
https://github.com/tensorflow/tensorflow/tree/v1.8.0/tensorflow/contrib/cmake/external
Do you mean all these packages with cmake are needed?
May I ask did you successfully use or test this tensorflow_static
lib?
And what additional libs did you use please?
Hi, I also encountered the same problem, did you solve it?