Questions tagged [bazel-cpp]
48 questions
3
votes
0 answers
How to link dynamically only with some libraries with bazel?
There are certain libraries, like gflags that have global state. I'm in a situation where main executable and dynamically loaded plugin (.so) both use gflags. In both cases bazel will link gflags statically. I need to change this, I somehow must…

Roman Byshko
- 8,591
- 7
- 35
- 57
2
votes
1 answer
In Bazel, with a `configure_make` rule, how can you deliver `.la` files?
Still working on a rule building xmlsec1, I'm trying to define .la files to be part of my build artifacts:
configure_make(
name="xmlsec1",
lib_name="xmlsec1",
lib_source=":all_srcs",
configure_command="configure",
…

frans
- 8,868
- 11
- 58
- 132
2
votes
0 answers
How to fix `ld: warning: -undefined dynamic_lookup may not work with chained fixups`on macOS M1?
I get always the linker warning
ld: warning: -undefined dynamic_lookup may not work with chained fixups
when building my C++ project with Bazel.
bazel clean && bazel test --config=macos //...
My question is how can I fix/prevent this?
On Windows…

Vertexwahn
- 7,709
- 6
- 64
- 90
2
votes
1 answer
Replacing compiler_suite with toolchains+platform: how to --config the compiler?
I've set up my bazel crosstool so that I can specifically select the compiler that I want: gcc9, gcc10, ..., clang12, clang13... This works great.
bazel build --compiler=clang13 //:target
I'm scratching my head wondering how I achieve this with…

Zendel
- 485
- 3
- 14
2
votes
2 answers
How to reference bazel c++ protobuf output headers in a different workspace/package
I just started using Bazel a couple days ago in hopes of something better than CMake. I have a small library that contains only protobuf definitions in its own repository. I've gotten bazel building the proto types and see them in the…

weagle08
- 1,763
- 1
- 18
- 27
1
vote
0 answers
Making cc_binary() rule always use a --define flag
I'm trying to build gRPC binaries in C++ but I don't need all the features provided by gRPC. In particular, I have no need for XDS support. I can disable it using the bazel build flag --define=grpc_no_xds=true, but it means I have to pass it all the…

Lajos Nagy
- 9,075
- 11
- 44
- 55
1
vote
0 answers
Bazel C++ header inclusion checking of direct dependencies
I have started using Bazel and ran into some behaviour which felt strange to me considering the documentation.
Consider the following example BUILD file:
cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
deps =…

cnarl
- 11
- 3
1
vote
1 answer
Generating C++ files via py_binary and genrule
I have a Python script named blob_to_cpp.py (located at scirpts/blob_to_cpp.py relative to the WORKSPACE.bazel file). The Python script takes an input file (e.g. weights/rt_alb.tza) and generates from that a C++ header (.h) and source file (.cpp)…

Vertexwahn
- 7,709
- 6
- 64
- 90
1
vote
1 answer
Extract compiler and linker flags from Bazel
I need to extract the compiler flags and linker flags for a certain application that is built by Bazel.
Is there a specific command to do so?

Ma.Ha
- 11
- 1
1
vote
1 answer
How to provide additional flags only to the native cc compiler?
In our project team we applications for micro-controller targets with arm-none-eabi-gcc. For running our testrunner we compile using the native cc compiler.
In our project team most use a Linux os, but some us a windows os (for reasons). The issue…

user2038134
- 37
- 6
1
vote
1 answer
Bazel: Reference binaries from packages in custom toolchain definition
Background
I'm trying to build a custom toolchain definition that references tool binaries from downloadable http_archive package.
It seems that if tool_path.path is relative Bazel treats it as relative to where toolchain is defined. Ex:…

Ghostrider
- 7,545
- 7
- 30
- 44
1
vote
1 answer
How do you access runfiles with Bazel 5.2.0 in c++
Im trying to access runfiles within c++. Im using Bazel 5.2.0. I tried to access like this:
std::string error;
std::unique_ptr runfiles(Runfiles::Create(argv[0], &error));
if (!runfiles) {
std::cerr << error << std::endl;
return…

Nov0cx
- 11
- 2
1
vote
1 answer
bazel rules_foreign_cc - //: depends on @local_config_cc//:cc-compiler-k8 in repository @local_config_cc which failed to fetch
I am an absolute beginner to bazel. I am trying to build a CMake based application using bazel through rules_foreign_cc
General Info:
OS: Ubuntu 20.04 LTS
Bazel version: Tried with both 3.4.0 and 5.0.0
CMake version: 3.19.5
My directory structure…

Indramani Arora
- 11
- 3
0
votes
0 answers
How do I get glog to use gflags when I'm using them as http_archives?
I have a Bazel WORKSPACE that looks like this:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_github_gflags_gflags",
sha256 =…

Bob
- 1
0
votes
2 answers
bazel build: how to know the time build cost?
I want to profile the time during the Bazel build, when i set --experimental_generate_json_trace_profile in command line, it output ERROR: Unrecognized option: --experimental_generate_json_trace_profile. it can show cost when i set…

GuangJun Liu
- 39
- 7