> For the complete documentation index, see [llms.txt](https://mbyzhang.gitbook.io/loongbian/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mbyzhang.gitbook.io/loongbian/os/install-cross-gcc.md).

# 安装交叉 GCC 编译器

交叉编译器：编译器本身运行的平台与该编译器编译出的二进制程序运行平台不一致。常用于在 PC（x86\_64）环境下编译其它平台（如龙芯）的程序。

Loongbian 提供宿主 x86\_64 平台，目标 Loongson（mips64el）平台的交叉编译器。

## 安装

进入 root 用户 shell（如使用 `sudo -i` 或者 `su root -l` 命令），然后运行

```
$ apt install ca-certificates apt-transport-https wget
$ echo "deb https://mirrors.teach.com.cn/toolchain/debian buster main" > /etc/apt/sources.list.d/loongbian-toolchain.list
$ wget https://mirrors.teach.com.cn/loongbian/loongbian-archive-keyring.gpg -O - | apt-key add -
$ apt update
$ apt install gcc-mips64el-linux-gnuabi64 binutils-mips64el-linux-gnuabi64
```

## 验证安装是否成功

```
$ mips64el-linux-gnuabi64-gcc -v
...
gcc version 8.3.0 (Debian 8.3.0-6+loongbian1)
```

确保版本号中包含 `loongbian` 字样。
