0

using Ubuntu 12 to cross compile arm code provides 2 gcc versions, 4.5 and 4.6. Installing both creates symlinks from the tools to the 4.6 version (e.g. arm-linux-gnueabi-gcc -> arm-linux-gnueabi-gcc-4.6). Is there an easy way to switch back and forth from having e.g. gcc symlinked to 4.5 or 4.6 ? I can write scripts that hack away at the symlinks but I'm hoping there's an Ubuntu way to do that already. thanks!

2 Answers 2

1

The alternatives system allows you to have a symlink you can swing around at will.

Sign up to request clarification or add additional context in comments.

5 Comments

alternatives looks interesting but these Ubuntu pkgs are not built using it. Looking at /usr/bin/arm-linux-gnueabi-gcc it is a direct symlink to /usr/bin/arm-linux-gnueabi-gcc-4.6 and not to /etc/alternatives as the alternatives pkg seems to require.
You can always provide your own.
agreed. But the reason I'm looking for something is native is so it doesn't break on upgrades of the pkgs. But definitely if I can't find a native option then this is the next-best it seems
They're just symlinks. As long as the executable pathnames don't change it'll still work.
the symlinks have been created by the pkg install so they will/might be overwritten on a pkg upgrade if I do something that the pkg isn't aware of. I still like this 'alternatives' option though so I'll probably give it a try and hope it doesn't get overwritten :)
0

A better and cleaner approach imho (and exactly what i do) is:

  1. Get the archive version, (Do not use apt)
  2. extract it in your home or /usr/share
  3. Create some alias in your ~/.bashrc like

    alias sourcery2009 = 'CROSS_COMPILE=/usr/share/arm-2009q3/bin/arm-none-eabi-' alias sourcery2010 = 'CROSS_COMPILE=/usr/share/arm-2010q1/bin/arm-none-eabi-' 
  4. When compiling (linux), use make zImage sourcery2009, this step varies a lot depending on what project you're compiling and how they take the location/prefix about the toolchain you want them to use, For many projects with simple makefiles, you'd have to do edits in makefile to change the path or make it take the toolchain path as an arg.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.