当前位置:网站首页>配置交叉编译工具链和环境变量
配置交叉编译工具链和环境变量
2022-07-04 05:30:00 【宁静致远2021】
配置交叉编译工具链和环境变量
原文链接:https://blog.csdn.net/qq_56926420/article/details/122890366
1 设置交叉编译工具链
交叉编译工具链用来在Ubuntu主机上编译应用程序,而这些应用程序是在ARM等其他平台上运行。
设置交叉编译工具主要是设置PATH, ARCH和CROSS_COMPILE三个环境变量,下面介绍具体设置方法。
设置这3个环境变量有多种方法,任意选择其中一种方法即可,建议使用“永久生效”的方法。录制视频时我会使用多种开发板,所以在视频里我总是使用“临时生效”的方法。
库环境变量设置:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/X11/lib:$LD_LIBRARY_PATH/
1.1 永久生效
如需永久修改,请修改用户配置文件。
注意:如果不会使用vim命令,可以使用图形化的编辑工具,执行:gedit ~/.bashrc
vim ~/.bashrc
(1)
在行尾添加或修改,加上下面几行(第3行第4行为一行命令):
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 命令使其生效,这条命令是加载这些设置的环境变量。
设置完毕后,要执行 source ~/.bashrc 命令使其生效,这条命令是加载这些设置的环境变量。
[email protected]:~$ source ~/.bashrc
[email protected]:~$ arm-buildroot-linux-gnueabihf-gcc -v
1.2 临时生效
也可以手工执行“export”命令设置环境变量,该设置只对当前终端有效(另开一个终端需要再次设置)。
(1)
执行以下3个命令,第3个命令很长,需要包含第四行全部复制:
[email protected]:~$ export ARCH=arm
[email protected]:~$ export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
[email protected]:~$ export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
1.3 手动指定
先设置PATH环境变量,然后在make编译时指定ARCH架构 CROSS_COMPILE交叉编译工具链(执行make命令时指定的参数,只对当前命令有效;下次执行make时仍需要再次指定那些参数)。
(1) 示例
[email protected]:~$ export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
[email protected]:~$ make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
[email protected]:~$ export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin
[email protected]:~$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
2 测试交叉编译工具链
2.1 测试环境变量
[email protected]:~$ echo $ARCH
arm
[email protected]:~$ echo $CROSS_COMPILE
arm-buildroot-linux-gnueabihf-
2.2 测试交叉编译器
执行以下命令,结果见后图:
[email protected]:~$ arm-buildroot-linux-gnueabihf-gcc -v
(1).
配置环境变量一:
使用export命令直接修改PATH的值,
如交叉编译工具链安装完后,
执行以下命令或者执行
export PATH=$PATH:/opt/hisi_linux/x86-arm/arm-himix100-linux/bin
说明:/opt/hisi_linux/x86-arm/arm-himix100-linux/bin为编译安装的目录
(2).配置环境变量二:
通过修改用户目录下的~/.bashrc文件进行配置:
在行尾添加或修改,加上下面一句
export PATH=$PATH:/opt/hisi_linux/x86-arm/arm-himix100-linux/bin
设置完毕后,要执行 source ~/.bashrc 命令使其生效,这条命令是加载这些设置的环境变量。
环境变量配置方法:
直接定义
export
Shell 配置文件
与 Bash Shell 有关的配置文件主要有
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
/etc/bashrc
/etc/bash.bashrc
/etc/profile.d/*.sh
Shell 执行顺序
/etc/profiles->/.profile(/.bash_profile、~/.bash_login)
修改配置文件
全部用户、全部进程共享:/etc/bash.bashrc
一个用户、全部进程共享:~/.bashrc
shell启动方式对变量的影响
子shell进程中执行:/bin/bash会创建shell子进程和./
当前进程中执行:source和.
3 如何添加交叉编译工具链(toolchain)到环境变量?(–sysroot路径)(新:ubuntu交叉编译工具链环境变量的配置)
边栏推荐
- ping端口神器psping
- SQL performance optimization skills
- Risc-v-qemu-virt in FreeRTOS_ Lock mechanism analysis of GCC
- 简易零钱通
- ETCD数据库源码分析——初始化总览
- Wechat applet +php realizes authorized login
- 企业级日志分析系统ELK(如果事与愿违那一定另有安排)
- Etcd database source code analysis - initialization overview
- LC weekly 300
- Google Chrome browser will support the function of selecting text translation
猜你喜欢
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
C # character similarity comparison general class
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
BUU-Reverse-easyre
2022年A特种设备相关管理(电梯)考试题模拟考试平台操作
VB. Net GIF (making and disassembling - optimizing code, class library - 5)
LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052
Accidentally deleted the data file of Clickhouse, can it be restored?
谷歌 Chrome 浏览器将支持选取文字翻译功能
One click filtering to select Baidu online disk files
随机推荐
Signification des lettres du module optique et abréviation des paramètres Daquan
LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052
Leetcode 184 Employees with the highest wages in the Department (July 3, 2022)
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
BUU-Pwn-test_ your_ nc
[paper summary] zero shot semantic segmentation
Penetration tool - sqlmap
JS string splicing
2022年A特种设备相关管理(电梯)考试题模拟考试平台操作
flink1.13 sql基础语法(一)DDL、DML
光模块字母含义及参数简称大全
c语言经典指针和数组笔试题解析
LabVIEW错误对话框的出现
js获取对象中嵌套的属性值
Remote desktop client RDP
Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
Supplement the JS of a video website to decrypt the video
Wechat applet +php realizes authorized login
1480. 一维数组的动态和
BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述