0

What is the best way to build C++ code that uses the dlib library using Bazel? I.e., what would the BUILD rules look like?

I tried following the answer for OpenCV as follows, but had no luck:

cc_library(
  name = "dlib",
  srcs = glob(["build/dlib/*.so*"]),
  hdrs = glob(["dlib/*.h"]),
  includes = ["include"],
  visibility = ["//visibility:public"], 
  linkstatic = 1,
)

1 Answer 1

2

I think I figured it out. Assuming dlib was unzipped to /opt/dlib-19.2 and built in /opt/dlib-19.2/build.

In your WORKSPACE file:

new_local_repository(
  name = "dlib",
  path = "/opt/dlib-19.2",
  build_file = "dlib.BUILD",
)

In dlib.BUILD:

cc_library(
  name = "dlib",
  srcs = glob(["build/dlib/*.so*"]),
  hdrs = glob(["dlib/**/*.h"]),
  includes = ["."],
  visibility = ["//visibility:public"], 
  linkstatic = 1,
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.