linux2.6.30.4内核移植(6)——移植应用程序hello world常见的错误:-bin/sh ./hello not found

通常在开发板上搭建好开发平台后,我们会试着移植一个最简单的应用程序Hello world来测试一下。初次尝试,我们经常会碰到的问题就是,在开发板上运行./hello的时候出错:-bin/sh ./hello not found

遇到这种错误,原因有如下两种:

一、在配置Busybox的时候,如果选择了Busybox Settings—>Build Options—>Build BusyBox as a static binary (no shared libs)选项,那么出现上述错误的原因是:在宿主机上交叉编译hello.c的时候,没有加上-static编译选项。因为默认是使用动态链接库的。使用如下命令重新编译hello.c:

arm-linux-gcc –static –o hello hello.c

如此之后,惊喜就会出现了!

image

image

二、在配置BusyBox的时候,如果没有选择Build BusyBox as a static binary (no shared libs)选项

image

而且,在交叉编译hello.c的时候也没有加-static(这种情况下不加就对了),那么出错的原因是根文件系统中(lib目录下)没有相应的动态库。为图方便,你可以拷贝一个完整的lib库过来(当然,不会全部用得到),再次尝试,你也会发现惊喜!!!

运行成功时截图如下:

image

原文地址:https://www.cnblogs.com/nufangrensheng/p/3671248.html