以helloworld程序为例(源代码如下):
#include<stdio.h>
int main()
{
printf("helloworld\n");
return 0;
}
首先在我的虚拟机里使用arm-linux-gcc 编译程序 :arm-linux-gcc -o helloworld helloworld.c
生成helloworld, 拷贝到开发板上,执行./helloworld
结果 bash: helloworld : No such file or directory
解决步骤:
(1)权限问题,chmod 777 helloworld
结果无效,还是一样。
(2)在虚拟机上使用arm-linux-readelf -a helloworld
找到Program Headers:
中 [Requesting program interpreter: /lib/ld-linux.so.3]
然后去开发板当中的lib目录中发现缺少 ld-linux.so.3
备注:我用的交叉编译器版本arm-linux-gcc -v 查询为4.3.2版本。
执行./helloworld返回的 No such file or directory 并不是指找不着helloworld这个文件而是指的/lib/ld-linux.so.3这个文件或者其它的helloworld所依赖的动态库。
到虚拟机中交叉编译工具链中的/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib目录中找到 ld-linux.so.3
而经查询ld-linux.so.3 只是一个链接符号,由lib-2.8.so链接而成
(我使用nfs挂载的根文件系统)
于是将lib-2.8.so 拷贝到开发板的文件系统中的lib目录,并在虚拟机上所挂载的根文件系统的目录里使用命令: ln -s ld-2.8.so ld-linux.so.3 #生成符号连接文件ld-linux.so.3
然后查询开发板lib目录,发现ld-linux.so.3
再次执行./helloworld
显示 helloworld 成功。
最后执行我需要的文件命令时又提示出现其他的错误,于是我想干脆把/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib 中的所有文件拷贝到开发板lib目录中去,结果如我所愿。成功执行。
期间我把生成的helloworld 放到同实验室师兄的板子上去执行,结果成功,于是我怀疑开发板的环境有问题,还重新烧录了系统,结果错误也没有解决。
最后还要感谢楼主的不放弃,讲真,选择了这条路真的会遇到许许多多的困难,在此感谢我的爱豆曾经鼓励我:只要有信心的话无难事。
真的是这段时间吃饭走路睡觉都在想这个问题出在了哪里,为此也冷落了女朋友,真的对不起。
在此感谢一些博客的博主(看了你们的文章楼主才受此启发,有了解决新思路):
http://blog.csdn.net/dlutxie/article/details/8645051
http://blog.csdn.net/harry_helei/article/details/5740456
http://blog.csdn.net/david_20121688/article/details/7477019
https://wenku.baidu.com/view/1a145c1b5acfa1c7aa00ccbb.html
http://blog.csdn.net/david_20121688/article/details/7477019
http://www.cnblogs.com/amboyna/archive/2008/02/06/1065322.html
http://www.2cto.com/os/201306/222628.html
http://blog.csdn.net/remme123/article/details/9250765
https://wenku.baidu.com/view/dd361310770bf78a652954f8.html
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。