ID482769950

关于linux下运行应用程序时候提示: -/bin/sh: xxx:not found的解决办法

关于mini2440上-/bin/sh: 命令:not found的解决办法

我按照mini2440的移植手册移植了linux内核和文件系统不同的是我用的交叉编译器是最新的4.4.1而没有用天嵌科技提供的交叉编译器,当我移植好了yaffs文件系统,想写个helloworld程序在开发板上测试下,我把编译好的helloworld文件放到yaffs文件系统的/usr/bin目录下,但当我运行/usr/bin/helloworld命令是提示“-/bin/sh: /usr/bin/helloworld: not found”,一开始我以为是helloworld没有运行权限,不过我给了它运行权限还是提示同样的错误。我在网上搜了下找到了原因:只所以提示“-/bin/sh: /usr/bin/helloworld: not found”这个,是因为我没有拷helloworld所需的库文件。那怎么才能知道helloworld需要哪些库文件呢,可以这样,在命令行输入arm-linux-readelf -a helloworld 命令然后在输出的内容中找到Program Headers:节这里就有helloworld所需的库文件如下图:

关于linux下运行应用程序时候提示: -/bin/sh: xxx:not found的解决办法 - 徐仁俊 - 徐仁俊的博客

看来我们需要ld-linux.so.3这个库,在你的交叉编译器中找到这个库文件把它拷到我们文件系统的/lib目录中然后烧到开发板中再次运行/usr/bin/helloworld结果提示“/usr/bin/helloworld: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory”有效果了,最起码不是前一个错误提示了,这就证明方法对头,我们看一下上面的错误这次直接提示所需的库文件了,我们按提示把libgcc_s.so.1拷到文件系统的/lib中,然后再次运行,又提示“/usr/bin/helloworld: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory”还是少库文件,我们再把这个也拷到文件系统的/lib中,这次总算是行了,终于看到“hello world”。

 


评论