我陷入了交叉编译的世界,这并不是那么阳光。
我正在尝试为我的BeagleBone Black(运行TI Cortex-A8处理器)编译一个简单的hello world应用程序。
首先,我使用gcc
在x86上成功编译并运行了hello world应用程序。
然后我将我的编译设置更改为以下内容:
arm-linux-gnueabi-gcc -c -O0 -g3 -Wall main.c -o bin/obj/main.o
arm-linux-gnueabi-gcc bin/obj/main.o -o bin/hello_world
我使用SCP将文件传输到BeagleBone,并使用chmod +x hello_world
设置了可执行权限。
在运行./hello_world
后,唯一的回应是:
-bash: ./hello_world: No such file or directory
file
命令的输出结果与 /sbin/init
命令的结果相同,正如我所期望的:
$ file hello_world
hello_world: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x24b659b7a41fe043a6f4649d4ebfb5e692ebf0c7, not stripped
$ file /sbin/init
/sbin/init: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd21f6957ec031a27d567b3d5e6aa14b9e0c30c37, stripped
ldd
的结果是:
$ ldd hello_world
not a dynamic executable
我尝试添加了适当的平台和CPU类型,并将我的编译更改为:
arm-linux-gnueabi-gcc -c -O0 -g3 -Wall -march=armv7-a -mtune=cortex-a8 main.c -o bin/obj/main.o
arm-linux-gnueabi-gcc bin/obj/main.o -o bin/hello_world
起初,我的操作出错了,显示文本文件繁忙
,但之后我再也没有遇到这个错误了,现在变成了没有这个文件或目录
。我猜那次的错误可能只是一个错误的转移或其他什么问题。
/bin/hostname
复制到我正在运行的目录中,它可以正确地执行。 - Chris Watts