'C TensorFlow "undefined reference to `_imp__TF_Version'" [duplicate]

I am trying to get tensor flow working and so far I have this:

I installed TF from https://www.tensorflow.org/install/lang_c

I am running on Windows 10 and have copied and pasted the contents of the TF lib and include folders to their respective folders in MinGW. I then copied and pasted the example code from the website under a file named 'hello_tf.c' in VS Code. Any time I try to build it, or run it from the command line using "gcc hello_tf.c -ltensorflow -o hello_tf" it results in this error:

6: undefined reference to `_imp__TF_Version'
collect2.exe: error: ld returned 1 exit status

I cannot seem to find an answer that applies to both my situation and my operating system.

Code:

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());
  return 0;
}


Solution 1:[1]

Add the tensor flow import lib to your gcc command line:

gcc hello_tf.c -o hello_tf tensorflow.lib

See this page for more information on linking dlls on Windows: Link against a Windows .dll+.lib file combination with GCC under Cygwin?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bill Morgan