我想在tensorflow中添加第三方C库,以便我可以在其中一个示例中使用它。似乎没有任何例子可以遵循,所以任何帮助都将受到赞赏。
这是我使用event2作为第三方C库的工作。
我创造了一个' ln -s'在tensorflow / third_party中提供event2 / headers:
=> e
THIRD_PARTY /事件2 / BUILD:
ls -al ~/code/tensorflow/third_party/event2
lrwxr-xr-x 1 XXXX staff 25 May 17 16:03 ~/code/tensorflow/third_party/event2 -> /usr/local/include/event2
/usr/local/include> ls event2
BUILD bufferevent_struct.h event_compat.h listener.h thread.h
buffer.h dns.h event_struct.h rpc.h util.h
buffer_compat.h dns_compat.h http.h rpc_compat.h visibility.h
bufferevent.h dns_struct.h http_compat.h rpc_struct.h
bufferevent_compat.h event-config.h http_struct.h tag.h
bufferevent_ssl.h event.h keyvalq_struct.h tag_compat.h
在tensorflow / examples / label_image / BUILD中,我添加了对libevent的引用以及使用events2库的测试文件:
licenses(["notice"])
cc_library(
name = "event2",
srcs = glob( [ "*.h" ] ),
visibility = [ "//visibility:public" ],
)
它编译得很好,但是当我运行二进制文件时,我得到以下错误:
cc_binary(
name = "label_image",
srcs = [
"main.cc",
"my_new_file_using_events.c",
"my_new_file_using_events.h",
],
linkopts = ["-lm", ],
copts = [ "-Ithird_party", ],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/core:framework_internal",
"//tensorflow/core:tensorflow",
"//third_party/event2:event2",
],
)
libevent.a,libevent.dylib和其他libevent * libs位于/ usr / local / lib中。根据nm,event_base undefined。
dyld: lazy symbol binding failed: Symbol not found: _event_base_new
Referenced from: /Users/XXXX/code/tensorflow/bazel-bin/tensorflow/examples/label_image/label_image
Expected in: flat namespace
dyld: Symbol not found: _event_base_new
Referenced from: /Users/XXXX/code/tensorflow/bazel-bin/tensorflow/examples/label_image/label_image
Expected in: flat namespace
[1] 41395 trace trap bazel-bin/tensorflow/examples/label_image/label_image
如何解决此链接错误?感谢。
答案 0 :(得分:0)
我们不是缺少event2来源吗?另外,我想你想把.h放到cc_library(
name = "event2",
hdrs = glob( [ "*.h" ] ),
srcs = glob( [ "*.cpp" ] ),
visibility = [ "//visibility:public" ],
)
属性中。
{{1}}
这有帮助吗?