Skip to content
Advertisement

cross compilation for ARM: error no such file or directory/command not found

I have written simple Hello world program and compiled it with gcc-arm-linux-gnueabi compiler. It compiles well but when i try to execute it on ARM machine it complains “no such file or directory”. I think gcc-arm-linux-gnueabi is for embedded Linux only due to e(mbedded)abi. Is it different from ARM Linux ABI?

Please help me to solve this problem

code is here

#include "stdio.h"

int main(void) {
  printf("Hello world !n");
  return 0;
}

compiled as

arm-linux-gnueabi-gcc -Wall -o crosscomp hello.c

When i execute this crosscomp on target ARM machine error is crosscomp no such file or dir

EDIT When I was using arm-linux-gnueabi-gcc the entry point was not matching with the target machine entry point (readelf -l crosscom) but when I compiled with aarch64-linux-gnu-gcc entry point matched with target machine. But now error becomes permission denied on ./crosscomp. I tried with sudo which says crosscomp: no such command.

Note I posted same question on askubuntu https://askubuntu.com/questions/904685/cross-compilation-for-arm-error-no-such-file-or-directory but got no response.

The output of readelf is as below

ELF Header:

 Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0x400470
  Start of program headers:          64 (bytes into file)
  Start of section headers:          4488 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         29
  Section header string table index: 26

Advertisement

Answer

This peculiar error message happens when the dynamic loader required by a particular executable is missing.

You can find out the name of the dynamic loader that you need by applying readelf to the problem executable. On my x86-64 Linux box, for example

$ readelf -l /bin/ls | grep 'program interpreter'
  [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

(“program interpreter” is another name for “dynamic loader”.)

So, run the above command on your crosscomp binary on your development box. (If you don’t have readelf or you get error messages, try arm-linux-gnueabi-readelf.) The file named after “program interpreter:” needs to exist on your target ARM machine. If you don’t know where to get it, please post the output of the above command + ls -l of the directory that should have the missing file in it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement