C/C++ TensorFlow hello_tf.c:(.text+0xa):对"TF_Version"的未定义引用
C/C++ TensorFlow hello_tf.c:(.text+0xa): undefined reference to `TF_Version'
你好,我正在尝试将TensorFlow用于C/C++。目前,我正在尝试让他们在安装说明中提供的基本程序进行编译。
https://www.tensorflow.org/install/install_c
我正在运行Ubuntu的x86_64机器上工作。我相信我把图书馆安装得很好。当我列出/usr/local/文件夹中的目录时,我会在其中看到tensorflow。
$:ls/usr/local/include/
tensorflow
然而,当我尝试编译他们提供的基本程序时,它在gcc和g++中都失败了
$:gcc-o测试hello_tf.cpp
/tmp/cczK3WZs.o:在函数"main"中:
hello_tf.cpp:(.text+0x5):对`tf_Version'的未定义引用
collect2:错误:ld返回1退出状态
$:g++-o测试hello_tf.cpp
/tmp/cl7FitR.o:在函数"main"中:
hello_tf.cpp:(.text+0x5):对`tf_Version'的未定义引用
collect2:错误:ld返回1退出状态
除了按照建议运行ldconfig以安装到系统目录之外,安装时一切都很顺利。
$sudo ldconfig/sbin/ldconfig.real:
/usr/lib/libusbredirparser.so.1不是符号链接
/sbin/ldconfig.real:/usr/lib/libid3tag.so.0不是符号链接
/sbin/ldconfig.real:/usr/lib/libusbg.so.0不是符号链接
/sbin/ldconfig.real:/usr/lib/libusbmuxd.so.2不是符号链接
/sbin/ldconfig.real:/usr/lib/libmtp.so.9不是符号链接
/sbin/ldconfig.real:/usr/lib/libmad.so.0不是符号链接
/sbin/ldconfig.real:/usr/lib/libusb-1.0.so.0不是符号链接
/sbin/ldconfig.real:/usr/lib/libusbredirhost.so.1不是符号链路
尽管如此,这些文件似乎不会影响相关程序的编译。当我运行疑难解答编译命令时,它似乎可以工作。我不知道为什么这是
g++-I/usr/local/include-L/usr/local/lib hello_tf.cpp-lensorflow
hello_tf.cpp文件被编译为对象。因为在您的程序内部,您调用的函数名称编译器无法在您的代码链接器内部找到,所以需要查找其他地方来找到它们,以允许对象调用这些函数的代码。选项L(-L/usr/local/lib)告诉它应该在哪些目录中查找,L(-L tensorflow)告诉它应该检查哪些模块。请记住,-l应该出现在翻译单元(hello_tf.cpp)之后。
在这里发布问题之前,你应该做一些研究。您链接的页面将"-L"替换为导出LIBRARY_PATH。。。但我不认为你的程序在没有-l的情况下编译。
我遇到了同样的问题,但我的情况不同。我不明白为什么,但g++的顺序或参数在CentOS和Ubuntu上不同。
这在CentOS上没有错误,但在Ubuntu:上失败
#source file comes last
g++ -ltensorflow -o prog prog.cpp
在Ubuntu:上它必须按以下顺序
#source file comes first
g++ prog.cpp -o prog -ltensorflow
Ubuntu中的订单很重要。这条线给我一个错误
gcc-I~/include-L~/lib hello_tf.c-o hello_tf
/tmp/ccAXMBn1.o:在函数
main': hello_tf.c:(.text+0x5): undefined reference to
TF_Version'中
解决方案:
gcc-I~/include-L~/lib hello_tf。c-lensorflow-o hello_tf
/hello_tf
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 为什么 -mmacosx-version-min=10.10 不阻止使用标记为从 10.11 开始的函数?
- C++ Version Of Double.longBitsToDouble
- 使用 适用于 Android 和 iOS 的 tf-lite C++ API
- 在 tensorflow c++ 中是否有等效的tf.convert_to_tensor?
- 编译一个自定义的tf操作,其中输入是5d张量
- Linux C++编程:为什么连接是.so,生成的可执行依赖库是.so.version
- 保存在(Python)tensorflow中的权重未加载到C++tf中
- QT "relocation error" / "no version information available"运行时错误
- 在 OpenGL 中在 Mac 上编译着色器时出现"version not supported"错误
- 使用 Boost ASIO 和 SSL 时出现"Wrong Version Number"错误 (C++)
- 由于错误'wrong version number'无法完成握手
- Windows 10 环境中的"This version of XAudio2 is available only in Windows 8"错误
- C++是否有相当于tf.lite.Interpreter.get_input_details的等价物
- 如何使用C_API导入经过训练的 tf.contrib.learn.dnnclassifier
- 如何从 cv::Mat (C++) 转换为 tf.placeholder(C++ Boost.Python)
- MAC OpenGL 着色器错误:"version '150' is not supported "
- opengl version from glxinfo
- 如何保存RNN的状态以从TF中的图中提交
- 不使用系统Protobuf库时的"Protobuf compiler version doesn't match library version 3.6.1"