Trying to run a cross-compiled executable on target device fails with: No such file or directory

后端 未结 3 741
小蘑菇
小蘑菇 2021-02-05 16:04

I\'ve got caught in the not-so-sunny world of cross-compilation.

I\'m trying to compile a simple hello world application for my BeagleBone Black (which runs a TI Cortex-

3条回答
  •  忘掉有多难
    2021-02-05 16:58

    How to identify the problem?

    file cross_compiled_executable
    

    Contains something like:

    interpreter /lib/ld-uClibc.so.0
    

    and the problem is that that file does not exist on the target.

    How to solve the problem?

    Use a proper compiler, either:

    • the person who created the disk image must provide you the cross compiler or tell you exactly how to build it, e.g. with crosstool-ng. For BeagleBone asked at: Toolchain to crosscompile Applications for BBB
    • compile your own image and cross compiler, e.g. with Buildroot. Here is a generic QEMU example. Buildroot has BeagleBone support.
    • use a native compiler on the target. But generally targets are much slower than your host, and space constrained, so you likely don't want to do this.

      You might also be able to use a functional emulator such as QEMU to build, and then only run the programs on a slower platform, e.g. gem5 or a slow board.

    Just hacking up the interpreter is potentially not enough, notably you have to ensure binary compatibility between the program and the target libc, or program and kernel interfaces (syscalls, /proc, etc.) if you try to use -static (the target kernel might be too old and not contain the required interfaces). The only robust solution is to use the correct toolchain.

提交回复
热议问题