Software⏱️ 3 min read📅 2026-06-11

How to Fix gcc-4 Error – macports gcc select error trying to exec i686-apple-darwin11-llvm-gcc-4.2

gcc compiler error on macports installation

Quick Answer: Try removing the original Apple's provided gcc version by deleting the symlink and then reinstalling port select to set the default compiler correctly.

The 'macports gcc select error trying to exec i686-apple-darwin11-llvm-gcc-4.2' issue affects users who have installed GCC 4.7 from macports on OS X 10.7 (Lion) and are experiencing problems with the default compiler selection.

This issue can be frustrating for developers who rely on GCC for their projects, as it prevents them from using the default compiler without manually specifying the path to the desired version.

🛑 Root Causes of the Error

  • The primary reason for this error is that macports does not properly handle the default compiler selection when using the 'port select' command. When a new version of GCC is installed, macports may not update the default compiler path correctly, leading to issues with the default compiler selection.
  • An alternative reason for this issue could be that the system's PATH environment variable is not being updated correctly after installing or updating GCC.

🔧 Proven Troubleshooting Steps

Resolving the issue by modifying the macports configuration

  1. Step 1: To resolve this issue, edit the macports configuration file to set the default compiler path. Open the /etc/macports/default.conf file in a text editor and add the following line: defaults.write('gcc', mp_gcc_path='/usr/bin/i686-apple-darwin11-llvm-gcc-4.2')
  2. Step 2: Restart the macports service by running the command '/usr/sbin/service macports restart' to apply the changes.
  3. Step 3: Verify that the default compiler selection has been updated correctly by running the command 'port select gcc mp-gcc47' and checking that the output shows the expected path.

Resolving the issue using a symbolic link

  1. Step 1: As an alternative, create a symbolic link to the desired version of GCC in /opt/local/bin. Run the command 'sudo ln -s /usr/bin/i686-apple-darwin11-llvm-gcc-4.2 /opt/local/bin/gcc' to create the symbolic link.
  2. Step 2: Verify that the symbolic link has been created correctly by running the command 'ls /opt/local/bin/gcc' and checking that it points to the expected path.

🎯 Final Words

By following either of these methods, users should be able to resolve the 'macports gcc select error trying to exec i686-apple-darwin11-llvm-gcc-4.2' issue and use the default GCC compiler without issues.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions