ubuntu交叉编译环境搭建

450 阅读1分钟

ubuntu创建book用户并添加权限

创建book用户

sudo adduser book

修改/etc/sudoers文件,添加book ALL=(ALL:ALL) NOPASSWD: ALL

image.png

切换到book账户登录

su book

配置交叉编译环境

配置 repo

下载 repo 工具前需要设置 git 的邮箱和用户名,git 邮箱和用户名请根据 个人情况进行配置。

book@100ask:~$ git config --global user.email "user@100ask.com"
book@100ask:~$ git config --global user.name "100ask"

下载 BSP

1、 git clone https://e.coding.net/codebug8/repo.git

2、 mkdir -p 100ask_imx6ull-sdk && cd 100ask_imx6ull-sdk

3、 ../repo/repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify

4、 ../repo/repo sync -j4

image.png

Ubuntu 压缩,再传回 Windows

配置交叉编译工具链

交叉编译工具链用来在 Ubuntu 主机上编译应用程序,而这些应用程序是在ARM 等其他平台上运行。设置交叉编译工具主要是设置 PATH, ARCH 和 CROSS_COMPILE 三个环境变量,下面介绍具体设置方法。 源码、交叉编译工具链都是存放于/home/book 目录下,如需永久修改,请修改用户配置文件: vim ~/.bashrc

export ARCH=arm
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin

设置完毕后,要执行
source ~/.bashrc
命令使其生效,并通过
arm-buildroot-linux-gnueabihf-gcc -v

image.png