gcc for arm process

hi,

correct me if am wrong, as per gcc doc gcc is able to compile code for different target systems such as ARM, ARC etc. I tried for compiling ARM but failed to do so.
getting below error:

gcc -mcpu=arm920t -c avg.c -o agv_arm
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
avg.c:1: error: bad value (arm920t) for -mtune= switch

any idea or hint whats am doing wrong. Can you please explain compilation steps for different targets. I am using intel i386 machine with gcc 4.1.2

Thanks...

It can't compile for different architectures unless you have a version configured to do so. For the 99% of people who don't need them, the code and headers to compile ARM, SPARC, MIPS, and other foreign binaries would be a pointless waste of space. When I tried developing for OpenWRT, their CVS repository installed it's own whole dedicated compiler!

Even if configured for ARM it probably won't be producing binaries quite the way you want them -- compile an ARM executable under linux and you'll get an ARM Linux executable, not one for a foreign OS, because you compiled it with linux headers...

As Corona688 says, you need a special type of compiler for that.

What you wanna do is called "Cross compilation" for ARM platform, so you need the following tools, which are just a version of gcc that creates binaries for ARM.

If you're trying to compile a Linux kernel for an ARM platform, just use the variables ARCH and CROSS_COMPILE as follow:

root@box:~# make ARCH=arm CROSS_COMPILE=/path/to/arm-linux- 

Where 'arm-linux-' are the tools from the link i just left you.

Hi,

I knew to do a cross compilation we need library supporting cross compiled libraries. There is arm-linux-gcc tool chain available for that and also this will gonna execute on the platform for which it is compiled.

To do make, we have to write Makefile ..

My question was simple, let me make it more simpler, GCC has got compilation for target options
i.e. mcpu, march, etc How can we use that to compile a C code for ARM, MSP or ARC processors?
Can anyone give me sample steps for compiling?

Thanks...

We're not trying to withhold information from you. This isn't "easy".

Usually to build something you'd

  • Download it
  • Extract it
  • ./configure --help
  • ./configure
  • make
  • Attempt to install without overwriting any files from your good compiler(no sense having 2 broken compilers instead of 1 working one)

The ./configure step involves decisions on not just what architecture to use but where to keep headers, where to keep libraries, and how to use them. Usually these choices'd be made by the people managing your distribution. You may also need patches, again, usually provided by the people managing your distribution.

Yeah thats simple with autoconf and then make...

what will we do if we have just a hello world program and want to cross-compile it for MSP or PPC board ... the mcpu and march when can I use these options? OR are these just to make more optimum binaries for the running platform itself?

Are you talking about an MSP board running linux, or a standalone non-linux platform?