How to link a library build using make rule in bazel

Viewed 531

I have built a lib.so using make rule in bazel. How do I link this external lib.so to a regular cc_library rule. I tried adding it in deps, but the guide suggests that deps can have cc_library or objc_library targets.

Also, do I need to pass any specific linking options, and how can I read more about them?

1 Answers

In the BUILD file, create a cc_library target that imports the built lib.so for other cc_library targets to depend on:

cc_library(
    name = "lib",
    srcs = ["lib.so"],
    linkopts = ["...", "..."],
)

See the documentation on C++ use cases for more information.

Related