I want to use clang++ instead g++ to compile my c++ files while g++ is the system's default compiler.
I have tried sudo update-alternatives --install c++ c++ /home/guo/bin/clang++ 100
and set CC
environment. But they doesn't work. Bazel still uses g++ as compiler.
After an hour, Bazel uses clang++. But an error occurred.
ERROR: /home/guo/utils/lib/BUILD:2:1: C++ compilation of rule '//utils/lib:get_pdf' failed: linux-sandbox failed: error executing command /home/guo/.cache/bazel/_bazel_guo/d2d93a82f24e8dc5485ac1b29928428e/execroot/_bin/linux-sandbox ... (remaining 41 argument(s) skipped).
src/main/tools/linux-sandbox-pid1.cc:592: "execvp(/home/guo/lib/clang, 0x23abde0)": Permission denied
Target //utils/lib:get_pdf failed to buildenter code here
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.159s, Critical Path: 0.06s
Ps: /home/guo/lib/clang
is a directory, not a binary in my computer. I guess here should be /home/guo/bin/clang++
but I don't know how to let Bazel
know it.
Ps: It seems you need to restart
Bazel
server when you changed the environment.