Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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>
main()
{
printf("Hello World \n");
}
I found 2 ways to do this:
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
arm-elf-gcc 2.95.3-2 arm-elf C cross compiler
arm-gcc 3.4.4-2 The GNU C compiler for cross targeting ARM f
arm-glibc 2.3.5-2 The GNU C Library for cross targeting ARM fr
arm-kernel 2.6.10-2 The Linux kernel for ARM (AT91RM9200)
and also an "arm-linux-gcc".
First i compiled is with arm-elf-gcc:
Code:
arm-elf-gcc test.c
Output (Sry, but its German):
Code:
test.c:1: stdio.h: Datei oder Verzeichnis nicht gefunden
In english (self translated):
Code:
test.c:1: stdio.h: Can't find file or dictionary
Ok, that dont work.
Then i compiled it with the "arm-linux-gcc":
Code:
arm-linux-gcc test.c
There is no outpur, so i think it worked.
Then i copied the file on my SAM9-L9260, over Putty i executed the file:
Code:
./a.out
Output:
Code:
-bash: ./a.out: No such file or directory
I don't understand this error, because the file "a.ou" exists... (if i press "Tab" in Putty it autocomplete a.out)
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
Output:
Code:
test.c:1:19: error: stdio.h: No such file or directory
test.c: In function 'main':
test.c:4: warning: incompatible implicit declaration of built-in function 'printf'
It does not work too...
I don't know how i can compile code for my SAM9-L9260, pleae help me.
Then i copied the file on my SAM9-L9260, over Putty i executed the file:
Code:
./a.out
Output:
Code:
-bash: ./a.out: No such file or directory
I don't understand this error, because the file "a.ou" exists... (if i press "Tab" in Putty it autocomplete a.out)
You didn't say how you transferred a.out to your target host, but perhaps the file permissions were not preserved. If the file does not have execute permissions, try
Code:
chmod +x a.out
on the target host.
You can avoid the use of a.out as an output filename quite easily:
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
An sample ARM binary of mine shows:
Code:
ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.18, dynamically linked(uses shared libs), not stripped
Try to do this on the target host, if possible, to account for possible mangling of the object file during file transfer. BTW, how are you doing the file transfer? Are you sure that the file is being transferred intact? Since you say you used putty, I imagine you are using Windows, which may require special treatment of binary files to prevent translation of newlines, etc.
Now my HelloWorld works perfectly, but i have another problem:
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.
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.
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.
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"
This will generate a bigger executable as as this is statically linked, but it will take care of your problems of missing libraries. Static linking is probably not a good idea for your final product, but you can use it until you install all the required libraries on your target.
Quote:
by the way, what is the use of arm-linux strip?
The strip utility removes the debugging symbols from your executable, thus reducing its size
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.
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
Hi friends,
I've same problem with you, but I use armv5tel, I use this form:
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.
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
I solvent, I install arm-gp2x-linux-gcc helloWorld.c -o hello -static
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.