37

I am trying to install the gnu arm toolchain for ubuntu. I first downloaded the tar from CodeSourcery. However when I go into the bin folder, I cannot run any of the binaries. I have tried with ./ and without and putting it in the PATH and it keeps telling me "Command not Found" yet the file is there in the folder right in front of me. Then I tried sudo apt-get install gcc-arm-linux-gnueabi except after it says it has installed successfully, I cannot find it with whereis gcc-arm-linux-gnueabi. Can anyone help?

red0ct
  • 4,840
  • 3
  • 17
  • 44
user1952441
  • 405
  • 1
  • 5
  • 4
  • 1
    if you install from source code, you need compile the source and install the bin. However, if you download compiled bin, you can run it. could give more information, after you use apt to install it. try to use `sudo find / -name "*gcc-arm*"` to find if there are some bin – How Chen Jan 06 '13 at 07:46
  • 6
    apt-get install ia32-libs. You are trying to run 32 bit binaries on a 64 bit linux install. Been there, done that... – old_timer Sep 13 '13 at 04:45
  • For Mac and Win 10 you can refer to [this](https://stackoverflow.com/a/57897276/2441637) answer. – Hasan A Yousef Sep 11 '19 at 21:55
  • You can build it using the [crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) – NAND Mar 20 '23 at 19:52

12 Answers12

41

fixed, using:

sudo apt-get install gcc-arm*
Ahmed Mkaouar
  • 638
  • 6
  • 4
20

Are you compiling on a 64-bit OS? Try:

sudo apt-get install ia32-libs

I had the same problem when trying to compile the Raspberry Pi kernel. I was cross-compiling on Ubuntu 12.04 64-bit and the toolchain requires ia32-libs to work on on a 64-bit system.

See http://hertaville.com/2012/09/28/development-environment-raspberry-pi-cross-compiler/

Stacey Richards
  • 6,536
  • 7
  • 38
  • 40
  • 3
    On ubuntu, when i give this command, it throws error - Package ia32-libs is not available, but is referred to by another package. –  Dec 01 '14 at 22:37
  • 1
    @MadhavanKumar try this one sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 – Jeegar Patel Jan 06 '15 at 09:13
14

CodeSourcery convention is to use prefix arm-none-linux-gnueabi- for all executables, not gcc-arm-linux-gnueabi that you mention. So, standard name for CodeSourcery gcc would be arm-none-linux-gnueabi-gcc.

After you have installed CodeSourcery G++, you need to add CodeSourcery directory into your PATH.

Typically, I prefer to install CodeSourcery into directory like /opt/arm-2010q1 or something like that. If you don't know where you have installed it, you can find it using locate arm-none-linux-gnueabi-gcc, however you may need to force to update your locate db using sudo updatedb before locate will work properly.

After you have identified where your CodeSourcery is installed, add it your PATH by editing ~/.bashrc like this:

PATH=/opt/arm-2010q1/bin:$PATH

Also, it is customary and very convenient to define

CROSS_COMPILE=arm-none-linux-gnueabi-

in your .bashrc, because with CROSS_COMPILE defined, most tools will automatically use proper compiler for ARM compilation without you doing anything.

mvp
  • 111,019
  • 13
  • 122
  • 148
  • 1
    It's not a CodeSourcery convention, it's a GNU/GCC thing called a target-triplet which has the form *cpu-vendor-os* – iabdalkader Jan 06 '13 at 11:06
  • @mux: I did not say it was CodeSourcery convention. I only said that it is customary and most tools will start using it automatically (which very well may be because of GCC target-triplet thing). – mvp Nov 14 '13 at 04:39
6

if you are on 64 bit os then you need to install this additional libraries.

sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
  • 1
    On Debian 8 it seems the third one is missing: Package lib32bz2-1.0 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'lib32bz2-1.0' has no installation candidate – Will May 26 '17 at 13:16
6

got the same error when trying to cross compile the raspberry pi kernel on ubunto 14.04.03 64bit under VM. the solution was found here:

-Install packages used for cross compiling on the Ubuntu box.

sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev

-Download the toolchain

cd ~
git clone https://github.com/raspberrypi/tools

-Add the toolchain to your path

PATH=$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

notice the x64 version in the path command

Marc
  • 1,159
  • 17
  • 31
axodus
  • 69
  • 1
  • 1
6

I was also facing the same issue and resolved it after installing the following dependency:

sudo apt-get install lib32z1-dev
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
3

If you are on a 64bit build of ubuntu or debian (see e.g. 'cat /proc/version') you should simply use the 64bit cross compilers, if you cloned

git clone https://github.com/raspberrypi/tools

then the 64bit tools are in

tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64

use that directory for the gcc-toolchain. A useful tutorial for compiling that I followed is available here Building and compiling Raspberry PI Kernel (use the -x64 path from above as ${CCPREFIX})

RookieGuy
  • 517
  • 7
  • 18
  • 2
    For me on Debian 8, following the instructions here: [RPi kernel](https://www.raspberrypi.org/documentation/linux/kernel/building.md) I had to put the full PATH into CROSS_COMPILE despite having set PATH as told. So I had to do this: `sudo make ARCH=arm CROSS_COMPILE=/home/will/kernel/mybuild/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install > makemodules6.txt` – Will May 26 '17 at 13:36
2

You have installed a toolchain which was compiled for i686 on a box which is running an x86_64 userland.

Use an i686 VM.

strowger
  • 88
  • 6
  • 1
    With multiarch available on Linux this is hardly a good advice especially for something as small as setting up a compiler for cross-compiling. – rbaleksandar Aug 16 '15 at 18:00
2

Its a bit counter-intuitive. The toolchain is called gcc-arm-linux-gnueabi. To invoke the tools execute the following: arm-linux-gnueabi-xxx

where xxx is gcc or ar or ld, etc

liteflier
  • 327
  • 2
  • 8
1

try the following command:

which gcc-arm-linux-gnueabi

Its very likely the command is installed in /usr/bin.

user1055604
  • 1,624
  • 11
  • 28
1

I had to cross compile C code in Ubuntu for ARM. This worked for me:

$ sudo apt install gcc-arm-none-eabi

Later, tested it on the qemu emulator

#Install qemu
sudo apt-get install qemu qemu-user-static qemu-system-arm

#Cross compile "helloworld.c"
$ arm-none-eabi-gcc --specs=rdimon.specs   -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group helloworld.c -o helloworld

#Run
qemu-arm-static helloworld

Pe Dro
  • 2,651
  • 3
  • 24
  • 44
0

You can build it using the crosstool-ng

git clone https://github.com/crosstool-ng/crosstool-ng.git
cd crosstool-ng
git checkout crosstool-ng-1.24.0
./bootstrap
./configure --prefix=${PWD}
make && make install

To select the toolchain you want to build :

bin/ct-ng arm-unknown-linux-gnueabi

And make the right configuration:

bin/ct-ng menuconfig

Then start to build

bin/ct-ng build

Note: The build may take more than one hour.

NAND
  • 663
  • 8
  • 22