bazel 2.0: why cc_library under windows does not generate the dll but just the .lib

503 views
Skip to first unread message

Thierry_m

unread,
Feb 3, 2021, 1:58:31 PM2/3/21
to bazel-discuss
Hi,

We are trying to move from our current build flow with make to Bazel.
We noticed that the cc_library does not generate the dll. It is built after the executable it depend on is built.
it is not the same behavior as linux.
Is there any way to build the dll before building the exe?

I am using bazel 2.0 for our testing.
our dlls are loaded at run time.

Any pointer/help to be able to progress would be appreciated.

Thanks

Thierry

Konstantin

unread,
Feb 6, 2021, 9:46:29 PM2/6/21
to bazel-discuss
Hi Thierry,

Bazel support for Windows is rather limited and often not straightforward, but let me try to give you some hints.

-- cc_library does not generate the dll

1. cc_library rule CAN generate DLLs on Windows. For that to work you need to set "linkstatic" attribute to False and also request "dynamic_library" output group like this:
    --output_groups=dynamic_library
2. While the above works it is more common in Bazel to generate DLLs using cc_binary rule. Here is the example: https://github.com/bazelbuild/bazel/tree/master/examples/windows/dll

-- It is built after the executable it depend on is built.

As long as the library is in the "deps" list of the executable it should build first.

Konstantin
Reply all
Reply to author
Forward
0 new messages