How to add third party C library to tensorflow?
I want to add a third party C library to tensorflow so that I can use it in one of the examples. There don't seem to be any examples to follow, so any help would be appreciated.
Here's my work using event2 as a third party C library.
I created 'ln -s' in tensorflow / third_party to provide event2 / headers:
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
THIRD_PARTY / event2 / BUILD:
licenses(["notice"])
cc_library(
name = "event2",
srcs = glob( [ "*.h" ] ),
visibility = [ "//visibility:public" ],
)
In tensorflow / examples / label_image / BUILD, I added a link to libevent and my test files that use the events2 library:
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",
],
)
It compiles fine, but when I run the binary, I get the following errors:
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
libevent.a, libevent.dylib and other libevent * libs are in / usr / local / lib. according to nm, event_base is undefined.
nm -f label_image | grep event_base
U _event_base_dispatch
U _event_base_new
How do I resolve this binding error? Thank.
+3
source to share