How to install the standard version of C ++ when building with Bazel?

I am a little new to C ++. I know how to install a C ++ version using CMake, but I don’t know how to install a C ++ version in Bazel.

Maybe set using the copts parameter in cc_libary , but should I set this in each cc_libary ?

+10
source share
2 answers

Thus, a reliable solution for specifying the Bazel C ++ toolchain is to use the CROSSTOOL file. The CROSSTOOL wiki page may be helpful. To get started, you can read the wiki page with a custom set of tools. To find out what Bazel does when it automatically generates a cross-tool for you, you can read the auto-configuration blog post . And to get more examples of how to write functions and action_configs, take a look at CppActionConfigs.java .

Or just put build --cxxopt='-std=c++11' in .bazelrc (stored in your home or in the folder where the WORKSPACE file is located).

+11
source

bazel build --cxxopt='-std=c++11' main:hello-world This will work, but I'm wondering if there is a way to set this cxxopt globally, like CMAKE_CXX_FLAGS .

+5
source

Source: https://habr.com/ru/post/1258818/


All Articles