13

I'm trying a simple cross compile (cc) for an ARM-CORTEX-A9: To keep things simple thats the c-code:

#include <stdio.h>
int main()
{
   printf("Hello World!\n");
   return 0;
}

The native compilation on the arm works fine and is started with gcc helloworld.c -o helloworld whereas the cross compile is started with arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc

GCC Version:

nativ: gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) Target: arm-linux-gnueabihf

CC: gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-79) Target: arm-xilinx-linux-gnueabi

ABI from readelf:

readelf-nativ: OS: Linux, ABI: 2.6.31 readelf-cc: OS: Linux, ABI: 2.6.16

Linked libs - the cross compiled is statically linked so it shouldn't miss any libs:

root@localhost:/temp# ldd helloworld
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ed8000)
        /lib/ld-linux-armhf.so.3 (0xb6fce000)
root@localhost:/temp# ldd helloworld_cc
        not a dynamic executable

The Problem: the native program runs fine, the cc always ends up with:

root@localhost:/tmp# ./helloworld_cc
-bash: ./helloworld_cc: No such file or directory

Any hints, hopefully, I have included enough information.

edit

Linking it static does the trick, but now the size of the file is huge (678kB (CC-static) vs. 4kB(native)? Why is it missing libs even if it says it is not dynamically linked? Similar question: Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc

arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc -static
Community
  • 1
  • 1
eactor
  • 862
  • 3
  • 14
  • 34
  • Are you trying run ARM-CORTEX-A9 binary on x86 linux? – Sergei Nikulov Jun 05 '13 at 08:41
  • no it a Linaro/Ununtu running on the arm cortex a9 (xillinux on zedboard) http://xillybus.com/xillinux – eactor Jun 05 '13 at 08:46
  • ok. then check executable attribute on your binary. – Sergei Nikulov Jun 05 '13 at 09:25
  • i did chmod +x for both and doubled check graphicaly within the file browser properties – eactor Jun 05 '13 at 09:33
  • 1
    perhaps it is missed shared library on your target platform - here http://stackoverflow.com/questions/2716702/no-such-file-or-directory-error-when-executing-a-binary and here http://askubuntu.com/questions/73491/no-such-file-or-directory-for-existing-executable – Sergei Nikulov Jun 05 '13 at 09:43
  • I don't think the simple example has any libs, i checked with ldd and it says for the cc version not dyn. linked. I also updated my gcc cc toolchain to match the gcc versin 4.6.3 of the target plattform, still getting the same error (edited question) – eactor Jun 05 '13 at 12:54

1 Answers1

10

Ther was a missing link in the lib folder Linaro Ubuntu. It showed up with readelf -a

[Requesting program interpreter: /lib/ld-linux.so.3]

Putting the link lib/ld-linux.so.3 to lib/arm-linux-gnueabihf/ld-2.15.so

and it works.

Thanks for the help Sergey

eactor
  • 862
  • 3
  • 14
  • 34
  • 1
    This post is old but I have a similar issue to yours, but can't solve it, so wondering if you could take a look at my question - http://stackoverflow.com/questions/39920945/cross-compile-qt-5-helloworld-app-for-armv7l – kaushal Oct 07 '16 at 15:41