Installing using binary installer
注:二进制包,里面包括了编译好的可以直接使用的程序,只需要把它解压缩到你想要安装的目录就马上可以使用,很简单。
The binary installers are on Bazel’s GitHub releases page.
The installer contains the Bazel binary1. Some additional libraries must also be installed for Bazel to work.
Step 1: Install required packages 安装其他依赖包
First, install the prerequisites: pkg-config, zip, g++, zlib1g-dev, unzip, and python.
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
Step 2: Download Bazel 下载bazel包
Next, download the Bazel binary installer named bazel--installer-linux-x86_64.sh from the Bazel releases page on GitHub.
Step 3: Run the installer 命令安装
Run the Bazel installer as follows:
chmod +x bazel-<version>-installer-linux-x86_64.sh
./bazel-<version>-installer-linux-x86_64.sh --user
The --user flag installs Bazel to the $HOME/bin directory on your system and sets the .bazelrc path to $HOME/.bazelrc. Use the --help command to see additional installation options.
Step 4: Set up your environment 添加路径
If you ran the Bazel installer with the --user flag as above, the Bazel executable is installed in your $HOME/bin directory. It’s a good idea to add this directory to your default paths, as follows:
export PATH="$PATH:$HOME/bin"
# You can also add this command to your ~/.bashrc file. (手动添加路径,找到该文件,手动添加上面代码)
解决Bazel:Error: LinkageError occurred while loading main class com.google.devtools.build.lib.bazel.
原因是出现中文路径的问题,解决方法也很简单,把bazel--installer-linux-x86_64.sh复制到其他没有中文路径的文件下,再安装!!!
ok了