当前位置:网站首页>配置交叉编译工具链和环境变量
配置交叉编译工具链和环境变量
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交叉编译工具链环境变量的配置)
边栏推荐
- JS扁平化数形结构的数组
- Flask
- BUU-Real-[PHP]XXE
- 空洞卷积、可变形卷积、可变形ROI Pooling
- Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
- Flink1.13 SQL basic syntax (I) DDL, DML
- Input displays the currently selected picture
- Letter meaning and parameter abbreviation of optical module Daquan
- ping端口神器psping
- Trie number dictionary tree
猜你喜欢

transformer坑了多少算力

Just do it with your hands 7 - * project construction details 2 - hook configuration
![[Excel] 数据透视图](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)
[Excel] 数据透视图

RSA加密应用常见缺陷的原理与实践

Principle and practice of common defects in RSA encryption application

Graduation design of small programs -- small programs of food and recipes

Flask

Evolution of system architecture: differences and connections between SOA and microservice architecture

LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052

BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述
随机推荐
One click filtering to select Baidu online disk files
Use of hutool Pinyin tool
left_ and_ right_ Net interpretable design
Yyds dry goods inventory TCP & UDP
What are the reasons for the frequent high CPU of ECS?
Excel 比较日器
Google Chrome browser will support the function of selecting text translation
Graduation design of small programs -- small programs of food and recipes
Electronic components mall and data manual download website summary
卸载Google Drive 硬盘-必须退出程序才能卸载
企业级日志分析系统ELK(如果事与愿违那一定另有安排)
How to use postman to realize simple interface Association [add, delete, modify and query]
Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
Flink1.13 basic SQL syntax (II) join operation
Penetration tool - sqlmap
tutle时钟改进版
Signification des lettres du module optique et abréviation des paramètres Daquan
Just do it with your hands 7 - * project construction details 2 - hook configuration
Notepad++ -- display related configurations
一键过滤选择百度网盘文件