Compile Code for ARM-Processor
Hello,
Sorry i'm not very well in english, i hope you can read the text. I use a SAM9-L9260 with an AT91SAM9260-Processor. I installed a Debian-Linux as Operating System. I can communicate with RS232 (Serial) or over Ethernet with SSH (i use Putty). The Standart-Tools on Linux works fine, there are no problems. But now, i want to compile a Hello-World-Program for my Developer-Board. test.c (The code works on my Desktop-Debian): Code:
#include <stdio.h> First Way: Crosscompile the Code I Installed some packages to crosscompile the code: Code:
arm-binutils 2.16-2 The GNU binary utilities for cross targeting First i compiled is with arm-elf-gcc: Code:
arm-elf-gcc test.c Code:
test.c:1: stdio.h: Datei oder Verzeichnis nicht gefunden Code:
test.c:1: stdio.h: Can't find file or dictionary Then i compiled it with the "arm-linux-gcc": Code:
arm-linux-gcc test.c Then i copied the file on my SAM9-L9260, over Putty i executed the file: Code:
./a.out Code:
-bash: ./a.out: No such file or directory Ok, this way does not work. Second Way: Compile on the Target-System On the target is a gcc, so i thinked i can compile code with this. I executed: Code:
gcc-4.1 test.c Code:
test.c:1:19: error: stdio.h: No such file or directory I don't know how i can compile code for my SAM9-L9260, pleae help me. Thx, regards toredo |
Quote:
Code:
chmod +x a.out You can avoid the use of a.out as an output filename quite easily: Code:
gcc -o test test.c |
thx for the answer.
The rights of the a.out-file were ok. But thanks for the -o Parameter. regards toredo |
I'm not sure how/if bash detects whether a specified binary executable is a valid object file for the host it is to run on, but given your difficulties in building the object code, I would try to ascertain that your a.out (or test, now that you know about -o ) is valid for the target host. If you have 'file', you can use it to determine something about your executable.
Code:
file ./a.out Code:
ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.18, dynamically linked(uses shared libs), not stripped --- rod. |
Hello,
Thanks, now i found a valid crosscompiler (crosstool-linux-gcc-4.0.1-glibc-2.3.5.tar.bz2), and the new output of the "file"-Command is: Code:
./hello: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped Code:
libc6_2.3.6.ds1-13etch9_arm.deb The compiler only knows some packages, of course not all. But if i want to work with more packages, but i can't compile Binary using this packages. How can i add them to the compiler's "brain"? To install them on the target is no problem. Thanks for the answers. regards toredo |
Different question, so I suggest starting a new thread. My short answer is that I used Kegel's crosstool to generate my cross toolchain. I am now looking at the newer crosstool-ng. Both are easily found online.
--- rod. |
Hello everyone,
I am really new to this forum and i get the same problem with toredo. i am using linux 10.04 in my PC and i am using arm-linux-gcc to compile my helloworld program. the command is :"arm-linux-gcc -o hello hello.c". the output file "hello" is transferred with ftp. before transferring, i use command "bin" as in the tutorial i followed. To run the program, i am using ssh and type "./hello". the reply is like in toredo's case. i compare my output file with the one from example. the file size is different. the example version is about 3 kb and my compiled version is about 5 kb. is there anything wrong with my compiler? i am using arm-linux-gcc version 4.4.3. |
i have changed the permission with "chmod +x hello"
|
Try this
Hi, I solved with
$ arm-linux-gcc -o outputfile.exe inputfile.c $ arm-linux-strip outputfile.exe $ chmod +x outputfile.exe $ ./outputfile.exe because I had problems with the output file extension. The arm-linux-gcc makes a outputfile.exe ^_^ Maybe you must have the right cross-compiler (check it out) Break a leg |
Hi ninaeve
this still does not work on me.. i have tried using the makefile from example given and it give the same problem when executed. i am using arm-linux-gcc v 4.4.3. by the way, what is the use of arm-linux strip? is there any effect for different file extension in linux? toredo said thad we can compile our c program in the target processor. how can i do that? because i can't find any gcc in my linux. |
Hi toredo,
Try this, this might fix your problem you stated in the first post Code:
"arch"-linux-gcc -static "source-file.c" Quote:
|
:o I didn't see that it was a 3 year old thread... :mad: wiguna149 maybe you can try what i told in my previous post
|
hi qwerty4061
i realized that the first post was old enough and i am still getting the problem nowadays.i was a little embarassed when i realized this. by the way my problem was solved just now. i have just changed my arm-linux-gcc version from 4.4.3 to 3.2.2 and it is working now for the helloworld program. tonight i will make some test for another program. Thanks everyone |
Quote:
I've same problem with you, but I use armv5tel, I use this form: armv5tel-redhat-linux-gnueabi-gcc readFiles.c -o provaFile -static But another file just compile until 2007 is :ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped. Althought that I've the same armv5tel, the file would like to compile it return : ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped The difference that I can see (SYSV) and for GNU/Linux 2.6.14, because I use virtual machine with a fedora 13. I need to know ,what happen? Thanks |
Quote:
I solvent, I install arm-gp2x-linux-gcc helloWorld.c -o hello -static |
All times are GMT -5. The time now is 04:27 AM. |