1

I use OSX10.12, I try to use OpenCV in tensorflow, I use the first method which is mentioned in this question.

I build my code successfully but there are some questions as following when I execute it:

dyld: lazy symbol binding failed: Symbol not found: __ZN2cv6String8allocateEm
Referenced from: /Users/philokey/Practice/github/tensorflow/./bazel-bin/tensorflow/examples/test_cv/test_cv
Expected in: flat namespace

The build file is as following:

cc_binary(
name = "test_cv",
srcs = [
    "test_cv.cc",
],
deps = [
    "@opencv//:opencv",
],
)

How can I solve this problem?

Community
  • 1
  • 1
Philokey
  • 491
  • 2
  • 5
  • 14

1 Answers1

1

You need to make sure you updated following files under tensorflow directory, correctly:

in WORKSPACE - (./tensorflow/tensorflow/WORKSPACE) add following:

new_local_repository(
  name = "opencv",
  path = "/usr/local/",
  build_file = "opencv.BUILD",
)

opencv.BUILD - (./tensorflow/tensorflow/opencv.BUILD) add following:

cc_library(
  name = "opencv",
  srcs = glob(["lib/*.dylib*"]),         <<<<<<<
  hdrs = glob(["include/**/*.hpp"]),
  includes = ["include"],
  visibility = ["//visibility:public"],
  linkstatic = 1,
)

[NOTE] for different operating systems, different dynamic libraries are created, example:

  1. linux -> *.so,
  2. windows -> *.dll, and
  3. on OSx -> *.dylib

Even then if you face any problems please set DYLD_PRINT_LIBRARY environment variable to check if the correct libraries are linked, at times different versions of libraries may keep you busy.

Milind Deore
  • 2,887
  • 5
  • 25
  • 40