title: Tensorflow Op and Kernel do not register on Windows with CMAKE
body: <p>I am building a custom Tensorflow Op and Kernel Implementation in C++ targeting Tensorflow r1.3. I successfully build and link the op library by using the suggestions form <a href="https://github.com/tensorflow/models/issues/1103" rel="nofollow noreferrer">this bug report</a>.</p>
  
  <p>My code is pretty much the boilerplate op code from the Tensorflow API.</p>
  
  <p>When I load the ops with <code>tf.load_op_library()</code> I can use the ops in Python and create a graph with them and save this as graph definition. When I subsequently try to load the Ops then in C/C++ with <code>TF_LoadLibrary()</code> the call returns OK as Status but the ops cannot be found. </p>
  
  <p>I always get the error:</p>
  
  <blockquote>
    <p>Not found: Op type not registered '...' in binary running on ... Make sure the Op and Kernel are registered in the binary running in this process.</p>
  </blockquote>
  
  <p>I am aware of this article: <a href="https://stackoverflow.com/questions/37548662/understand-op-registration-and-kernel-linking-in-tensorflow">Understand Op Registration and Kernel Linking in TensorFlow</a>.
  Both the Op registration and kernel registration code are to be found in the op library code.</p>
  
  <p>I tried:</p>
  
  <ol>
  <li>Moving the Op registration code to my own c++ code. That works but then the error changes that no kernels are registered for that op which doesnt help either.</li>
  <li>Moving the Kernel registration code to my own c++ code. That doesnt work because the Linker cant find the nvcc compiled operators.</li>
  <li>Putting the Op and Kernel Registration Macros inside a DllMain method instead of putting them directly into the code. Didnt help either.</li>
  <li>Procmon.exe and Dependency Walker both show that the DLL of the Op is loaded
  correctly. So somehow Tensorflow does not register the Ops with the
  cmake based build setup. Building tensorflow takes 3-4 hours, when I
  have to build tensorflow completely for my op changes is not really
  practicable.</li>
  <li>I was digging through the Tensorflow Codebase and found this code snippet which i tried to call directly <code>Register("MyOp", TF::OpRegistry::Global());</code></li>
  <li>Initializing the Python Interpreter with <code>Py_Initialize()</code> from C++ and run the python import command from within C++ with <code>PyRun_SimpleString</code></li>
  </ol>
  
  <p>Anyone has tried that already and succeeded? Any Input? I am desperate.</p>