C TensorFlow“对`_imp__TF_Version’的未定义引用”

xiaoxingxing tensorflow 272

原文标题C TensorFlow “undefined reference to `_imp__TF_Version'”

我试图让张量流工作,到目前为止我有这个:

我从 https://www.tensorflow.org/install/lang_c 安装了 TF

我在 Windows 10 上运行,并已将 TF lib 的内容复制并粘贴到 MinGW 中它们各自的文件夹中。然后,我从网站上复制并粘贴了示例代码,并将其粘贴到 VS Code 中名为“hello_tf.c”的文件下。任何时候我尝试构建它,或者使用“gcc hello_tf.c -ltensorflow -o hello_tf”从命令行运行它都会导致这个错误:

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

我似乎找不到适用于我的情况和我的操作系统的答案。

代码:

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

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

原文链接:https://stackoverflow.com//questions/71918358/c-tensorflow-undefined-reference-to-imp-tf-version

回复

我来回复
  • Bill Morgan的头像
    Bill Morgan 评论

    将张量流导入库添加到您的 gcc 命令行:

    gcc hello_tf.c -o hello_tf tensorflow.lib
    

    有关在 Windows 上链接 dll 的更多信息,请参阅此页面:在 Cygwin 下使用 GCC 对 Windows .dll+.lib 文件组合进行链接?

    2年前 0条评论