How to specify -std=c++11 option in bazel BUILD file?
Asked Answered
R

3

7

How to add this option into a target description section?

Thanks.

Rate answered 13/2, 2019 at 8:38 Comment(0)
F
9

Add bazel build --cxxopt='-std=c++11' to .bazelrc file.

Fieldpiece answered 13/2, 2019 at 8:41 Comment(1)
Thanks, I tried it, actually adding --cxxopt='-std=c++11' to .bazelrc should work.Rate
T
1

export BAZEL_CXXOPTS=-std=c++11

see source

Tabulator answered 23/4, 2020 at 1:32 Comment(0)
E
0

Besides setting it globally in .bazelrc or using BAZEL_CXXOPTS , you can also set them individually for each target in their cc_binary or cc_test rules:

cc_binary(
    name = "target1",
    srcs = ["target1.cc"],
    copts = ["--std=c++17"],
)

cc_binary(
    name = "target2",
    srcs = ["target2.cc"],
    copts = ["--std=c++14"],
)
Enciso answered 1/5, 2022 at 19:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.