macOS : configure: error: C compiler cannot create executables

By | December 20, 2019

Having some issues using the GCC compiler? The problem may show up under different circumstances, such as :

– Invoking the GCC compiler trying to compile an application manually using “sudo ./configure”. In such case, an output similar as below will be shown :

– Trying to upgrade outdated packages after updating MacPorts (which invoke GCC as well) using “sudo port upgrade outdated”. In such case, an output similar as below will be shown :

In that case, that issue happened after Xcode update (which also update the Xcode Command Line Tools that provide GCC). Each time Xcode is updated, licence agreement for GCC must be accepted before it can be used.

If the similar condition apply to your case, it is most likely the issue. You can easily find out by issuing the following command :

If this issue match your case, the following output will be returned :

Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.

In order to read and accept the license, run the following command as suggested :

Just type “accept” whenever you are done reading the license.

Once done, you may use the “gcc -v” command again to see if the GCC compiler is now usable, if successful, a similar output as below will now be shown :