主题 : 新手问关于hello的执行问题 复制链接 | 浏览器收藏 | 打印
kec
级别: 新手上路
UID: 467
精华: 0
发帖: 3
金钱: 30 两
威望: 30 点
综合积分: 6 分
注册时间: 2008-04-07
最后登录: 2009-07-14
楼主  发表于: 2009-07-10 10:22

 新手问关于hello的执行问题

我按照说明书建立好ARM Linux交叉环境,并用gcc成功编译了hello.c,并将hello下载到开发板了。
在开发板上linux系统起来之后在终端输入:./hello提示:
-sh: ./hello: not found

然后我用静态编译了hello   gcc -o hello -static hello.c

之后生成的hello在开发版运行时却出现Segment fault

我在网上查了 解决方法:意思是没有相应的动态链接库.将需要的连接库放到/lib中,或用变量LD_LIBRARY_PATH指定动态库位置,或在/etc/ld.so.conf中写入库的位置.

但我是一个新手,看了这个方法还是不会具体操作,希望各位高手能帮我解决一下这个问题。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-07-10 11:06
先在你的Linux PC上用
$file hello
看一下编译出来的hello是什么格式的执行档,正确的格式应该类似下面这样:
setuid setgid ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped
"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."
kec
级别: 新手上路
UID: 467
精华: 0
发帖: 3
金钱: 30 两
威望: 30 点
综合积分: 6 分
注册时间: 2008-04-07
最后登录: 2009-07-14
2楼  发表于: 2009-07-12 23:47
我的格式是

ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

请问版主大人这是哪里不对呢
级别: 新手上路
UID: 7366
精华: 0
发帖: 45
金钱: 450 两
威望: 440 点
综合积分: 90 分
注册时间: 2009-07-12
最后登录: 2010-07-15
3楼  发表于: 2009-07-14 15:09
我这里的情况是
ELF 32-bit LSB executable, ARM, version 1, for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped
用了LART的编译器,测试结果是无论动态静态都能运行。

用了官网最新编译器就不行。文件格式信息大概是这样的
app: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, dynamically linked (uses shared libs), not stripped
在开发板上,如果用动态链接就说not found,如果是静态链接就说segmentation fault。所以估计是版本太新了吧。

推荐用LART的交叉编译器试试。

LART编译器的网站:http://www.lartmaker.nl/doc.php3
下载地址:http://www.lartmaker.nl/lartware/compile-tools/arm-linux-cross.tar.bz2
[ 此帖被singbenshor在2009-07-14 15:28重新编辑 ]