使用sudo执行gcc命令的时候提示找不到命令

前提:使用soc Hi3556v100  ubuntu 16.04  root下对整个程序make正常,

切换到本地用户名下对程序编译sudo make时报错

    make[3]: arm-hisiv600-linux-gcc:命令未找到。

查询arm-hisiv600-linux-gcc  -v发现编译链是存在的,但是sudo arm-hisiv600-linux-gcc  -v 显示不存在。

百度时有文章提到执行sudo时对PATH重定向了, 访问sudo vi /etc/sudoers 发现:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

看第三个Defaults,发现在执行sudo时PATH路径确实重新定向到secure_path,而此处确实没有arm-hisiv600-linux-gcc对应的环境变量。

修改: 

1.sudo chmod 755 /etc/sudoers

2.sudo vi /etc/sudoers
在secure_path中添加:/opt/hisi-linux/x86-arm/arm-hisiv600-linux/target/bin:/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin:

secure_path="/opt/hisi-linux/x86-arm/arm-hisiv600-linux/target/bin:/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

3.退出后权限修改回来  sudo chmod 555 /etc/sudoers

再次编译发现一切正常。

 

你可能感兴趣的:(Makefile,交叉编译链)