主题 : 求助:静态编译的helloworld 不能在mini2440运行!! 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 5924
精华: 0
发帖: 15
金钱: 95 两
威望: 31 点
综合积分: 30 分
注册时间: 2009-05-13
最后登录: 2015-01-21
楼主  发表于: 2009-10-29 19:37

 求助:静态编译的helloworld 不能在mini2440运行!!


代码:
#include <stdio.h>
#include <string.h>

int main()
{
  printf("helloworld\n");
}

编译:
arm-none-linux-gnueabi-gcc helloworld.c -o helloworld
这样编译的输出的是默认动态链接的helloworld,可以在mini2440的linux.2.6.29环境运行

arm-none-linux-gnueabi-gcc  -static helloworld.c -o helloworld
这样编译的输出的是默认静态链接的helloworld,在mini2440的linux.2.6.29环境运行时,会提示“非法指令‘


说明:
      编译kernel和kernel是同一个便要求,kernel编译选择了eabi。文件系统采用mini2440默认的。


求助各位:
  具体是什么原因导致的这个问题?我再网上搜了很久都没有什么结果,有人有相似的问题,说是sh的问题。是吗?




*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-10-29 20:22
用‘arm-none-linux-gnueabi-gcc  -march=armv4 -static helloworld.c -o helloworld’试试?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 5924
精华: 0
发帖: 15
金钱: 95 两
威望: 31 点
综合积分: 30 分
注册时间: 2009-05-13
最后登录: 2015-01-21
2楼  发表于: 2009-10-30 22:28

 回 1楼(kasim) 的帖子

谢谢,应该是编译器问题,采用mini2440自带编译可以运行了。发现它的arm-linux-gcc 是个脚本啊,内容就是arm-none-linux-gnueabi-gcc  -march=armv4