Fedora9安装篇(二):搭建交叉编译环境

来源:互联网 发布:贝聊软件下载 编辑:程序博客网 时间:2024/05/20 20:19

概要:PC机上出现bash: ./hello: cannot execute binary file原因;开发板上如何执行可执行文件。

 

     将arm-linux-gcc安装好后,编译生成helloWorld的可执行文件,在PC上输入./hello返回bash: ./hello: cannot execute binary file,而用gcc编译后的生成文件可以执行输出Hello World!

     在网上查了下,原来是用arm-linux-gcc生成的可执行文件不能再PC上执行,只能将可执行文件下载到Arm开发板上执行。

 

     通过串口将ALG341Hel.o下载到开发板,执行./ALG341Hel.o输出permission denied。在网上搜索这个问题,原来是文件权限不够,输入ls -l输出的ALG341Hel.o权限为读和写(rw),没有可执行(x),因此对其进行chmod 777 ALG341Hel.o后,就可以把所有的权限增加上,之后再执行./ALG341Hel.o就可以正常输出Hello World!了。

 

在开发板上具体执行过程如下(ALG341Hel.o为可执行文件):

[root@FriendlyARM /home]# ./ALG341Hel.o
-sh: ./ALG341Hel.o: Permission denied
[root@FriendlyARM /home]# ls -l
-rw-------    1 root     root         7975 Dec  3  2010 ALG341Hel.o
drwxrwxrwx    1 root     root          512 Aug 27  2006 plg
[root@FriendlyARM /home]# chmod 777 ALG341Hel.o
[root@FriendlyARM /home]# ./ALG341Hel.o
Hello World!
[root@FriendlyARM /home]# ls -l
-rwxrwxrwx    1 root     root         7975 Dec  3  2010 ALG341Hel.o
drwxrwxrwx    1 root     root          512 Aug 27  2006 plg
[root@FriendlyARM /home]#

 

指令:

查看某一文件的属性   ls -l ALG341Hel.o

增加某一文件中的一个属性: chmod +x ALG341Hel.o   增加可执行的属性

通过yum安装软件:yum install  **

 

参考资料:

mini2440用户手册:安装交叉编译环境,将Linux安装到开发板上,通过串口将可执行文件从PC机传入开发板。

交叉编译环境的安装:http://www.cnblogs.com/papam/archive/2009/11/19/1606197.html

arm-linux-gcc编译的程序在PC上不能执行:http://blog.sina.com.cn/s/blog_6439091b0100gshx.html

http://hi.baidu.com/cjjiloveu/blog/item/ad877639e490f1c8d4622512.html

http://blog.is36.com/cannot_execute_binary_file/

yum常用命令:http://www.linuxsky.org/doc/newbie/200801/230.html

chmod命令:http://www.chinalinuxpub.com/doc/manual/9.0/rhl-gsg-zh_CN-9/s1-navigating-ownership.html