PDA

View Full Version : Using updated GCC?




brent1a
Sep 18, 2008, 06:45 AM
I've successfully compiled and installed the newest gcc (4.3.2). How do I make Leopard use it now instead of it's default gcc 4.0?
thanks in advance
-b



darkwing
Sep 18, 2008, 07:43 AM
I've successfully compiled and installed the newest gcc (4.3.2). How do I make Leopard use it now instead of it's default gcc 4.0?
thanks in advance
-b

You don't want to try and change to a non-apple supplied GCC. They patch it to support their various extensions for OSX. You can use your new gcc to build your posix apps, but if you try and replace your dev tools with it you'll have problems.

If you want to use it yourself from the command line by default, you should put /usr/local/bin in your path ahead of /usr/bin and /bin. Because Apple sucks, I had to add the following line to my ~/.bash_profile:

export PATH=/usr/local/bin:$PATH

(This is assuming you installed gcc-4.3.2 to /usr/local/bin which you should have done.)

brent1a
Sep 18, 2008, 11:31 AM
I definitely don't want to try and replace what Apple has provided. I just want to try and use the new one from the command line.
However, since I'm a newb at the command line if you could please expound on what exactly I should add to my "sudo ./configure" "sudo make" commands so that I use the gcc-4.3.2 I'd be grateful. I'm not sure I completely understand what you've told me so far.

Cromulent
Sep 18, 2008, 11:43 AM
If you want to use it yourself from the command line by default, you should put /usr/local/bin in your path ahead of /usr/bin and /bin. Because Apple sucks, I had to add the following line to my ~/.bash_profile:

export PATH=/usr/local/bin:$PATH

(This is assuming you installed gcc-4.3.2 to /usr/local/bin which you should have done.)

Most BSD systems require that as they will only search system paths by default.

brent1a
Sep 18, 2008, 11:44 AM
I had to add the following line to my ~/.bash_profile:

export PATH=/usr/local/bin:$PATH

(This is assuming you installed gcc-4.3.2 to /usr/local/bin which you should have done.)

I understand about adding that to my .bash_profile but where exactly is that at? I can't seem to find it anywhere.

Can I just do this to add it permanently?

echo "export PATH=\"/usr/local/bin:$PATH\"" >> .bash_profile

darkwing
Sep 18, 2008, 11:48 AM
Most BSD systems require that as they will only search system paths by default.

Actually /usr/libexec/path_helper hard codes in the system paths and doesn't let you change their order. So adding /usr/local/bin to the paths won't work because defaults always go first. System level scripts should use absolute paths anyway. For the rest of what you do, you should be able to "replace" your system files by putting new versions or whatever in /usr/local and your own scripts will use those instead.

brent1a, you can use any text editor or anything to edit your .bash_profile file in your home directory. You will need to use the terminal, however, in order to edit it. You can make it easy on yourself by typing this in terminal:

open -a TextEdit ~/.bash_profile

brent1a
Sep 18, 2008, 11:59 AM
So I added /usr/local/bin to my .bash_profile however-
what you are saying is that adding export PATH=\"/usr/local/bin:$PATH\ wouldn't get the results that I would like, having gcc-4.3.2 used instead of the system gcc?