卫星电视接收卡使⽤arm-none-linux-gnueabi-gcc–ohellohello.c编译完。。。问题: 巨人传奇
使⽤arm-none-linux-gnueabi-gcc –o hello hello.c编译完成,在上运⾏出现报错:
-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_