Compiling my C++ code for ARM Architecture

15,760

You need more than just a switch, you need a cross-compiler. You can make your own, but probably the easiest way is :

  • Find the development tools for your board. It probably comes with a development kit that includes a cross-compilation toolchain

  • If you don't have these, you can try to install a precompiled cross-compilation like the ones provided freely by CodeSourcery

Then you have to make the location of your toolchain (look for something like arm-none-linux-gnueabi-gcc) available in your path.

Cross compiling simple project is then easy, just override the CC variable in your Makefile :

CROSS = arm-none-linux-gnueabi-
CC = $(CROSS)gcc
LD = $(CROSS)ld
Share:
15,760
M99
Author by

M99

Updated on June 04, 2022

Comments

  • M99
    M99 almost 2 years

    I am a java developer. I have some C++ code to make some system realted calls. This code is compiled on Intel 32-bit platform using GCC (I have make files) and it works fine on regular Intel based 32-bit linux machine. Now I need to run this on a linux OS running on Marvell ARM processor. When I load the shared objects in java I get the following error.

    cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)

    Please tell me how to resolve this issue. I looked at the GCC options and I found one option to specify the architecture (-march=armv5) and I can't compile with that option.

    Thanks in advance.

  • M99
    M99 over 13 years
    -mcpu is deprecated. if I use -march=armv5, i get the following error. error: bad value (armv5) for -march= switch
  • gravitron
    gravitron over 13 years
    In most cases (this case included) you need a cross compiler that targets the ARM environment and the compiler that produced the intel code will not know how to also compile arm code.