Search code examples
tensorflowstatic-linkingc-api

Tensorflow missing c_api from static library


I compiled static tensorflow library as in https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/makefile. I'm able to load and use my graph using C++ api. But when I try to switch to c_api, I get bunch of undefined reference to TF_*.

How to compile static tensorflow library with C interfaces (tensorflow/c/c_api.cc)?

I tried to add this sourcefile to tensorflow/contrib/makefile/Makefile but it produces set of undefined references as well.


Solution

  • Ok, the solution occurred to be pretty simple: 1) put "tensorflow/c/c_api.cc" as one of the sources in tensorflow/contrib/makefile/Makefile b/tensorflow/contrib/makefile/Makefile 2) put "#define __ANDROID__ 1" in top of tensorflow/c/c_api.cc. That will disable calls to undefined refs.