make:arm-linux-gnueabihf-gcc: Command not found

编译嵌入式Linux系统内核

编译时,输入make指令后,系统出现make:arm-linux-gnueabihf-gcc: Command not found这样的错误。

可能的原因:在root权限下,环境变量中没有添加arm-linux-gnueabihf-gcc所在的路径。

解决方法:在root用户下,进入/root目录下,用gedit ./bashrc打开.bashrc文件,在文件末尾加上export PATH=$PATH:<path>/bin

<path>代表arm-linux-gnueabihf-gcc所在的目录。下图是我在.bashrc末尾添加的

make:arm-linux-gnueabihf-gcc: Command not found

添加完,保存,退出文件编辑,再运行 source /root/.bashrc

接下来的操作都是在linux-socfpga目录下执行的。

然后直接使用下面的命令来指定处理器架构和交叉编译工具:

export ARCH=arm    //指定处理器架构为arm

export CROSS_COMPILE=arm-linux-gnueabihf-   //指定交叉编译工具

再使用make指令,运气好的话,可以直接编译成功,编译完生成的zImage镜像文件在linux-socfpga/arch/arm/boot目录中。

如果运气不好,输入arm-linux-gnueabihf-gcc -v,可能会报这样的错误:bash: /home/l000/tools/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-gcc: No such file or directory

这个错误是因为你没有安装lib32ncurses5 lib32z1所致,可以使用sudo apt-get install lib32ncurses5 lib32z1指令进行安装。

安装完再执行arm-linux-gnueabihf-gcc -v,如果此时报下面这样的错误
arm-linux-gnueabihf-gcc: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
是由于使用的64位版本的系统中的libstdc++6与编译器版本中的库文件发生了冲突  编译器中是32位而系统中是64位。使用sudo apt-get install lib32stdc++6 安装32位lib库,

安装完后,使用arm-linux-gnueabihf-gcc -v 查看交叉编译工具的版本信息,如果像我这样能查看到正确的版本信息,那就可以直接使用make指令开始编译内核了。

make:arm-linux-gnueabihf-gcc: Command not found

编译完之后将在arch/arm/boot下看到zImage文件。

make:arm-linux-gnueabihf-gcc: Command not found