【发布时间】:2015-11-24 18:10:24
【问题描述】:
我正在 tensorflow 框架中编写 C++ 代码,我想使用使用 makefile 编写的动态库。 在源代码中,我放置了头文件的路径:
#include "tensorflow/cc/include/libtrading/proto/tf_fix_client.h"
使用名为 fix_client(int argc, char **argv) 的函数 在 BUILD 文件中,我放置了动态库的路径,名为 libtrading.so:
cc_binary(
name = "session",
srcs = ["work/session.cc"],
copts = tf_copts(),
linkopts = [
"-lpthread",
"-lm",
#for libtrading
"-L/home/alessandro_mercadante/tensor_flows/tensorflow/tensorflow/cc/include/",
"-ltrading",
],
...
bazel-build 检索到以下错误:
bazel-out/local_linux-opt/bin/tensorflow/cc/_objs/session/tensorflow/cc/work/session.o: In function `main':
session.cc:(.text.startup.main+0x2b): undefined reference to `fix_client(int, char**)'
collect2: error: ld returned 1 exit status
【问题讨论】:
-
不是loader的问题,而是linker的问题,所以我觉得不是你猜的问题。
-
是的,库的位置没有错误。这不是错误。
-
我知道未定义参考问题背后的概念。我认为这与挡板的使用有关。希望有 bazel 编译方面的高手可以对这个问题提出一些有用的建议。
标签: c++ tensorflow bazel