1

Since I upgraded to OSX Ventura when I try to compile I get the message: gcc: error trying to exec 'cc1': execvp: No such file or directory

The same occurs when trying to build Ada programs with Visual Studio Code:

   [Ada]          hello_world.adb
gcc: error trying to exec 'gnat1': execvp: No such file or directory

gnat1 is available.

sudo find /opt -name "cc1"           
Password:
/opt/gnat-ce-2021/libexec/gcc/x86_64-apple-darwin15/10.3.1/cc1
/opt/GNAT/2019/libexec/gcc/x86_64-apple-darwin17.7.0/8.3.1/cc1
/opt/gcc-11.1.0/libexec/gcc/x86_64-apple-darwin15/11.1.0/cc1

Similarly for gnat1

My Path includes /opt/gnat-ce-2021/bin which worked under previous versions of Mac OSX.

Roger
  • 21
  • 2

1 Answers1

1

What version of Xcode (or the Command Line Tools) are you using? I have the CLTs,

$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 14.1.0.0.1.1666437224
volume: /
location: /
install-time: 1667592295
groups: com.apple.FindSystemFiles.pkg-group

You really need 14.1.

Is there something wrong with the permissions on gnat1, cc1? on this M1 mini I have

$ ls -l /opt/gnat-ce-2021/libexec/gcc/x86_64-apple-darwin15/10.3.1/cc1
-rwxr-xr-x  1 root  wheel  35799072 14 Jun  2021 /opt/gnat-ce-2021/libexec/gcc/x86_64-apple-darwin15/10.3.1/cc1

and no problems of the sort you're getting; BUT BUT there are all sorts of problems with earlier GCCs as supplied by myself or AdaCore, you need to define SDKROOT,

export SDKROOT=$(xcrun --show-sdk-path)

and then

$ /opt/gnat-ce-2021/bin/gcc hello.c -I$SDKROOT/usr/include -L$SDKROOT/usr/lib

If you were to try GCC 12.1, you'd get

$ /opt/gcc-12.1.0/bin/gcc hello.c
<built-in>: error: unknown value '13.0.0' of '-mmacosx-version-min'

... you need GCC 12.2 which no longer has the arbitrary upper limit on the OS major version.


You should be able to download the Alire toolkit compiler gnat-x86_64-darwin-12.2.0-1.tar.gz from here.

Strongly recommend to do this before unpacking:

xattr -d com.apple.quarantine gnat-x86_64-darwin-12.2.0-1.tar.gz
Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • I have XCode 14.1 and its Command Line Tools. I discovered that I had the Brew version of GCC 12.2 but its aliases in usr/local/bin are all gcc-12 etc so I set aliases in my .profile as gcc to each one. – Roger Nov 09 '22 at 06:02
  • Now a simple C file compiles and runs. I did try building GCC 12.2 myself but ran into a problem, then discovered that I had the Brew version so decided to try that. I'm still have trouble with gnat1 however. I've checked that its permissions are all OK. – Roger Nov 09 '22 at 06:10
  • I'm now having trouble finding a suitable GNAT to install. – Roger Nov 09 '22 at 06:15
  • Roger@Rogers-Mac-mini ~ % gcc --version gcc-12 (Homebrew GCC 12.2.0) 12.2.0 Trying to build alire but the gnat1 problem stopped that. – Roger Nov 09 '22 at 06:34
  • Homebrew’s GCC doesn’t support Ada, dammit – Simon Wright Nov 09 '22 at 09:13
  • I added a note on downloading a suitable (I hope :-) compiler at the end of the answer. – Simon Wright Nov 09 '22 at 09:18
  • I've installed gnat-x86_64-darwin-12.2.0-1 successfully. I seem to have had some success today but still not quite there. Your help is greatly appreciated. – Roger Nov 09 '22 at 12:48