Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Compiling for Arm armv5tejl

I am trying to cross compile a simple hello world program for a linux system.

I have the following information:

uname -a
Linux (none) 2.6.32.28 #130 PREEMPT Mon Feb 18 13:54:18 CST 2013 armv5tejl GNU/Linux

cat /proc/cpuinfo
Processor       : ARM926EJ-S rev 5 (v5l)
BogoMIPS        : 421.06 
Features        : swp half fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 5

Hardware        : KeyASIC Ka2000 EVM
Revision        : 0000
Serial          : 0000000000000000

I would like to know how to cross compile for this system. I have tried the following:

  • arm-linux-gnueabi-gcc helloworld.c -march=armv5 -o helloworld
  • arm-linux-gnueabi-gcc helloworld.c -mcpu=arm926ej-s -o helloworld

But when I try and run the executable I get the error message "command not found". I am probably not compiling it correctly but I don't know what compile options to use given the information I have.

(I know the helloworld.c is all working).

ls -l helloworld
-rwxr-xr-x    1 0        0             8428 Jan  1 00:00 helloworld

which helloworld
which: applet not found

I put busybox-armv5l on

busybox which helloworld
(no output)

ldd is also not on the system I am trying to compile for (its the transcend WifiSD card).

ls -ln /lib/libc*
-rwxrwxrwx    1 0        0           244279 Jan 19  2012 /lib/libc.so.0
-rwxrwxrwx    1 0        0            13043 Jan 19  2012 /lib/libcrypt.so.0
-rwxr-xr-x    1 0        0          1251776 Jan  1 00:00 /lib/libcrypto.so.0.9.8

I tried to run /lib/libc.so.0 to get version information and I got a segmentation fault. It seems compiling with -static fixed the issue. So I guess it was an issue with the libc library. Thank you for the help.

like image 304
Nick Horne Avatar asked Oct 21 '22 02:10

Nick Horne


1 Answers

I had to use -static flag to include c libraries in the binary. Thanks to auselen.

like image 146
Nick Horne Avatar answered Oct 30 '22 15:10

Nick Horne