Mark
Mark

Reputation: 1053

bazel: link to library that lacks 'lib' prefix

I have an external library ace.so.

cc_library(
    name='ace',
    hdrs=glob(['path/to/ace/**']),
    srcs=['path/to/ace.so'],
)

How do I go about linking to that library with bazel? I know a colon can be used when invoking gcc/g++ directly, but I'm not sure how to get the same behavior from bazel.

I've read the Importing precompiled C++ libraries doc, but I didn't see anything about using libs with an arbitrary prefix - or with no prefix.

As a temporary fix, I've added a symlink libace.so pointing to ace.so and changed the srcs line to match. While this works, I'd much rather convince bazel to use the lib as is.

Upvotes: 1

Views: 537

Answers (1)

Ondrej K.
Ondrej K.

Reputation: 9664

Looking around how information about libraries is being collected and passed around, I am afraid this (assumption that "plain" dynamic libraries are prefixed with lib and libfoo.so can be given as -lfoo is fairly hard coded at the moment. The same would not be true of it was considered a "versioned" (matches a pattern "^.+\\.so(\\.\\d+)+$") dynamic library, which would be passed as -l:foo.so.1. But unfortunately that does not really help you, because you'd still need to employ a similar workaround and create a fiction of versioning to boot. That said, as long as your solib filenames are given, the symlink sounds like a reasonably sane workaround.

Upvotes: 1

Related Questions