ARM上显示hello not found问题

elesun8 2015-01-16 11:16:39
ARM上显示hello not found问题
**************************环境参数************************************
mini2440 ARM Linux 启动内核信息如下:
Linux version 2.6.29.4-FriendlyARM (gcc version 4.3.2)
[PC 虚拟机 redhat Linux]# uname -r
2.6.18-53.el5
[PC 虚拟机 redhat Linux]# arm-linux-gcc -v
gcc version 4.3.2
[PC 虚拟机 redhat Linux]# gcc -v
gcc version 4.3.2
****************************问题出现************************************
[root] # ./hello
-/bin/sh: ./hello: not found
****************************解决步骤************************************

1.ARM上先确保文件权限
A.确保本文件夹下有hello这个可执行文件
B.确保hello具有执行权限ls -l;chmod +x hello

2.试一试静态编译make static是否可以
PC 虚拟机 Linux上#arm-linux-gcc -static -o hello.c hello
ARM Linux #./hello若可以,说明是动态编译缺少动态库导致的

3.查看所需要的动态库
PC 虚拟机 Linux上#arm-linux-readelf -a hello | grep NEEDED
出来的内容就是你需要的库,确保你的开发板上有这些库。
[root@localhost 01hello]# arm-linux-readelf -a hello | grep NEEDED
0x00000001 (NEEDED) Shared library: [libc.so.6]

[root@localhost 01hello]# cd /lib/
[root@localhost lib]# ls libc.so.6
libc.so.6
[root@localhost lib]# file libc.so.6
libc.so.6: symbolic link to `libc-2.5.so'
[root@localhost lib]# ls libc-2.5.so
libc-2.5.so
[root@localhost lib]# file libc-2.5.so
libc-2.5.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, not stripped

4.把需要的动态库及指向的连接cp到ARM /lib下
[ARM/lib] # ls
libc-2.5.so libc.so.6 modules
**************************有个疑问**********************************
libc.so.6 libc-2.x.so文件在PC虚拟机Linux/lib下 和 usr/local/4.3.2.../lib都有存在
我是拷贝哪个文件夹下的libc.so.6 libc-2.x.so到ARM开发板上
**************************问题仍然**********************************
为什么我还是出现了同样的问题
[root] # ./hello
-/bin/sh: ./hello: not found



...全文
308 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
袁保康 2015-03-06
  • 打赏
  • 举报
回复
遇到这种错误,使用strace工具让你的问题一目了然.
yzhiju 2015-02-13
  • 打赏
  • 举报
回复
引用 3 楼 elesun8 的回复:
libc.so.6 libc-2.x.so文件在PC虚拟机Linux/lib下 和 usr/local/4.3.2.../lib都有存在我是拷贝哪个文件夹下的libc.so.6 libc-2.x.so到ARM开发板上
开发板上的库跟pc机的库不一样 怎么直接拷贝上去用呢
lr2131 2015-02-11
  • 打赏
  • 举报
回复
极有可能,交叉编译工具用错了。 我已经遇到过多次这样的问题,文件一定在正确路径下,执行权限也没问题,但就是说找不到。 arm gcc有几种编译器,有linaro的,还有个什么的,反正编译器名字叫得都很像。 该用什么编译器,自己找找板子的资料,写个最简单的helloworld放到ARM上跑试试。
elesun8 2015-01-23
  • 打赏
  • 举报
回复
可能是 .so 不在 LD_LIBRARY_PATH 中???
elesun8 2015-01-23
  • 打赏
  • 举报
回复
libc.so.6 libc-2.x.so文件在PC虚拟机Linux/lib下 和 usr/local/4.3.2.../lib都有存在我是拷贝哪个文件夹下的libc.so.6 libc-2.x.so到ARM开发板上
elesun8 2015-01-16
  • 打赏
  • 举报
回复
确定hello在当前目录,用-static可以正常显示啊。
帅得不敢出门 2015-01-16
  • 打赏
  • 举报
回复
很怀疑你的hello在不在当前目录
SimIt-ARM-3.0 给予命令行ARM指令模拟器,短小精悍,是研究ARM处理器的好工具,该模拟器既可以运行用户级别的ELF程序,又可以模拟运行Linux操作系统;提供了简单易用的调试命令,可以逐条跟踪指令的执行。 SimIt-ARM-3.0-gk-20150902.tar.bz2 HowTo 0.what is SimIt-ARM-3.0 SimIt-ARM 3.0 is an instruction-set simulator that runs both system-level and user-level ARM programs, for more about it please read user's guide file. 1.how to build tar jxvf SimIt-ARM-3.0-gk-20150902.tar.bz2 cd SimIt-ARM-3.0-gk ./configure make make install After these steps, the ./build/bindirectory contains the following programs: ema An ARM interpreter. To test the installation was successful type ./build/bin/ema test/wc configure modifiy PATH environment variable: PATH=$PATH:$HOME/SimIt-ARM-3.0-gk/build/bin ; export PATH 2. how to use 2.1 run user-level ARM programs [root@ORA9 SimIt-ARM-3.0-gk]# cd gcc-asm [root@ORA9 gcc-asm]# more hello.c /* * hello.c * Tue Sep 8 10:13:40 CST 2015 */ int main() { printf("hello world\n"); __asm("mov r0,#2\n\t" "swi 0x1\n\t"); // syscall: exit(2); } [root@ORA9 gcc-asm]# arm-linux-gcc -v Reading specs from /usr/local/arm/3.4.1/bin/../lib/gcc/arm-linux/3.4.1/specs Configured with: /opt/crosstool/crosstool-0.28/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2 --with-float=soft --with-headers=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2/arm-linux/include --with-local-prefix=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 3.4.1 [root@ORA9 gcc-asm]# arm-linux-gcc hello.c -o hello -static [root@ORA9 gcc-asm]# ls -l hello* -rwxr-xr-x 1 root root 520775 Sep 8 10:18 hello -rw-r--r-- 1 root root 160 Sep 8 10:15 hello.c [root@ORA9 gcc-asm]# file hello hello: ELF 32-bit LSB executable, ARM, vers

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧