×
单片机 > 单片机程序设计 > 详情

ARM上运行可执行程序出现No such file or directory的问题

发布时间:2020-06-04 发布时间:
|

问题:

使用arm-none-linux-gnueabi-gcc –o hello hello.c编译完成,在ARM上运行出现报错:

-sh: ./hello: No such file or directory

原因:

因为我们的程序使用的是动态链接方式编译的,而ARM上的链接库文件路径不同,导致找不到文件,可以用gcc -static命令改用静态链接的方式编译:

arm-none-linux-gnueabi-gcc –o hello hello.c -static


编译器的架构有差 
这是发生在一次新的开发板的交叉编译中产生的,同样的程序用同样的工具链编译后,一个开发板正常,二另一个报No such file or directory,文件明明存在,这个问题在于arm-Linux-guneabi-和arm-linux-guneabihf-这两个链的差别在于hf二字,这个是浮点单元的支持与否,选择错误会导致上述错误发生。

用uname -a查看ARM的架构和Linux版本,举例:

root@imx6qsabresd:~# uname -a

Linux imx6qsabresd 3.14.28-1.0.0_ga+g91cf351 #14 SMP PREEMPT Tue Apr 25 16:25:22 CST 2017 armv7l GNU/Linux

查看执行程序的属性,举例:

zhao@zhao-VirtualBox:/home/nfs/file/ntp$ file ntpdate 

ntpdate: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

以上的情况就无法执行,显示“No such file or directory”,然后通过更换GCC成功了。新版本:

gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar.xz



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
采用AT89C2051的数字可调稳压电源单片机源程序