LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This 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

Reply
 
Search this Thread
Old 07-21-2008, 02:39 PM   #1
ra2008
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Rep: Reputation: 15
embedded modules -cross compile !


hi,
when compiling a module to my PC i type:
Code:
gcc -O2 -D__KERNEL__ -DMODULE -I/usr/src/linux/include -c helloworld_module.c -o helloworld_module.o
for cross compiling how is going to be the compiling command? is it just replacing "gcc" with e.g. "arm-linux-gcc" ???
 
Old 07-22-2008, 08:31 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Only if you built an 'arm-linux-gcc' or can install it as a package on your distro.

Otherwise I'd suggest going to the Linux From Scratch site and following the link to the CLFS project; read the section on setting up the cross-compiler. Note that CLFS uses the 'uClibc' library rather than 'glibc', so don't follow the instructions exactly unless you're also building for uClibc.

The steps go something like this:
1. Build a cross-compiler:
- BUILD is the architecture of the machine running the compiler to build the other compiler
- HOST is the machine which will ultimately run the program being built (the compiler)
- TARGET is the machine which you want the compiler (which is being built here) to build for - ARM (check for typical 'triplets')
Confusing enough yet? I hope I didn't mix up 'HOST' and 'TARGET' ... you'll find out soon enough I guess ...
2. Build the C library 'glibc' or 'uClibc' are both popular; uClibc if space is important to you; glibc is enormous. See the CLFS docs for tips on how to do it. You need system headers from the linux kernel - this is just the public API, not the kernel's private headers.
3. Rebuild the cross-compiler; now you can rebuild the tools to use only the specially built C library. There is some hacking involved so that, for example, the linker doesn't attempt to link to /lib/libc.so.

And there you have it - oh - just to keep things safe, it's useful to have a user account exclusively for cross-compiling; that way the environment can be set up to avoid a few annoying traps (mostly related to linking or accidentally running the wrong compiler).

Have fun. Since building the cross-compiler is such a big job the first time you do it, keep plenty notes - better still, write a script as you go along so it can all be rebuilt at the push of a button. The same goes for building the libs - and for that matter, any other software you may build with the cross-compiler.
 
Old 07-22-2008, 09:31 PM   #3
ra2008
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Original Poster
Rep: Reputation: 15
follow2

well
i have a cross compiler(arm-linux-gcc) that works fine with my embedded platform.
but for example;
a hello_world module on my PC is compiled using the "make" on the makefile.
how can i build a module on my PC using (cross compiler that i have ) and run it on my embedded board?
thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross Compile Embedded EmmaTheViking Linux - General 2 06-30-2006 07:39 AM
How to cross compile? jiyun0121 Linux - General 3 09-01-2005 07:15 PM
Qt Cross Compile werewolfolondon Linux - Software 2 02-25-2005 02:01 PM
Compile Error- /lib/modules/extra/modules.dep UpChuck Debian 2 01-11-2004 11:20 AM
uCLinux - Embedded Linux : Modules blietaer Programming 4 01-08-2004 05:55 AM


All times are GMT -5. The time now is 08:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration