tags:

views:

368

answers:

3

Hi,

I'm having a lot of trouble compiling the otherwise excellent Contiki OS on my macbook pro (with mac os x 10.6). Contiki actually uses a lot of GNU-specific features and options of GCC, AR, LD, and so on. So I installed those utilities via macports, but it looks like "port install binutils" does not install GNU ld, does it ?

So, the question is, how do I get GNU ld on my mac ? Is there a simple alternative to the hard-way (i.e. the wget, configure, make, make install way) ?

A: 
$ port info binutils
(…) Tools are prefixed with g to avoid conflicts with original tools. (…)
zoul
Sure, but :% ls /opt/local/var/macports/software/binutils/2.19_0/opt/local/bingaddr2line gnm granlib gstringsgar gobjcopy greadelf gstripgc++filt gobjdump gsize
Gyom
% ls /opt/local/bin/gldls: /opt/local/bin/gld: No such file or directory
Gyom
long story short, everything is there *but* ld, hence my question.
Gyom
Aha, you’re right. I’ve just installed binutils and have no gld either. Sorry for the false trace.
zoul
No worries :-) but do you know what's wrong with them ? Why on earth won't binutils install "ld" ??
Gyom
A: 

Generally you can link directly with gcc or g++ and don't need gld. Try setting LD to point to the compiler and see if it doesn't link for you.

Rob Napier
sure ; "gcc -l" will directly invoke /usr/bin/ld for you :-)
Gyom
Well that's less useful than I'd hoped...
Rob Napier
+1  A: 

As far as I can tell, GNU binutils does not support the Mach-O format. None of the documentation mentions it, and some Googling turns up some recent messages indicating that it is not supported.

Now, you mention the Contiki OS, which looks to me like an embedded operating system. Are you needing to compile to a native executable, or are you trying to cross-compile for some other environment? MacPorts does include several ports of binutils for cross compilation.

Brian Campbell
indeed ; my long term goal is to do cross-compilation, of course. But at first I wanted to try the "native platform" target, in order to get familiar with the programming model and all that. However it looks more and more like "native" means "GNU/linux" and only "GNU/linux" :-(
Gyom
It looks like you're right; they appear to need a GNU toolchain, which generally means Linux or Cygwin. You can always install Linux to a virtual machine. I've had good luck installing Ubuntu server edition (as it's lighter weight than the desktop edition, not including the all the desktop software) onto a VirtualBox VM http://www.virtualbox.org/ for a quick and easy free Linux VM.
Brian Campbell
Yep, thanks for your help. I'm now starting to play with debian in a virtualbox. after all, it will probably be cool to have a linux environment at hand as well.
Gyom