1

I know this has been answered before, but nothing I have seen has worked!!! I'm not panicking just slightly mad it's not working. It has never worked once. I tried:

adding gnat to the path again,

gcc -c -x ada hello.adb

notCoder
  • 37
  • 10
  • Try `gcc -c -x ada hello.adb`. – trashgod Mar 23 '21 at 01:11
  • @trashgod same error – notCoder Mar 23 '21 at 01:13
  • I get `error: invalid value 'ada' in '-x ada'` only when I remove GNAT from the path. – trashgod Mar 23 '21 at 01:19
  • @trashgod look at the i tried part – notCoder Mar 23 '21 at 01:21
  • Try `echo $PATH` to verify the `PATH` in the current shell. – trashgod Mar 23 '21 at 01:24
  • @trashgod /usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/Users/blessb/.rbenv/shims:/Users/blessb/perl5/perlbrew/bin:/Users/blessb/perl5/perlbrew/perls/perl-5.28.0/bin:/Applications/commands:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/go/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/blessb/opt/GNAT/2020/bin – notCoder Mar 23 '21 at 01:41
  • :/Users/blessb/.cargo/bin – notCoder Mar 23 '21 at 01:41
  • Try `which gcc` to see if another one is preempting `GNAT. – trashgod Mar 23 '21 at 01:44
  • @trashgod /usr/bin/gcc – notCoder Mar 23 '21 at 01:45

1 Answers1

3

I looks like /usr/bin appears in your $PATH before the desired path, /Users/blessb/opt/GNAT/2020/bin. The search for gcc finds the original, which appears to be unaware of Ada. One solution is to add the GNAT directory to the front of your PATH, so that it will take precedence.

export PATH=/Users/blessb/opt/GNAT/2020/bin:$PATH

As @Simon Wright comments, see Adding a new entry to the PATH variable in ZSH for additional details regarding path management.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • how do i do that – notCoder Mar 23 '21 at 01:54
  • uh...... /usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/Users/blessb/perl5/perlbrew/bin:/Users/blessb/perl5/perlbrew/perls/perl-5.28.0/bin:/Users/blessb/opt/GNAT/2020/bin: my path! :( gnatmake: error, unable to locate gcc – notCoder Mar 23 '21 at 01:56
  • it did not work. in fact, it stopped GCC from even being found! – notCoder Mar 23 '21 at 02:02
  • The exact formulation will depend your shell and where it stores your profile, e.g. `bash` and `~/.bash_profile`. You may need to check your GNAT installation, too. – trashgod Mar 23 '21 at 02:03
  • I use zsh as it is the default shell on macos catalina – notCoder Mar 23 '21 at 02:05
  • I don't use zsh; try invoking `/Users/blessb/opt/GNAT/2020/bin/gcc -c -x ada …` directly. – trashgod Mar 23 '21 at 02:09
  • now the question is how to fix: gnatbind -x hello.ali gnatlink hello.ali clang: error: unknown argument: '-gnatA' clang: error: unknown argument: '-gnatWb' clang: error: unknown argument: '-gnatiw' clang: error: unknown argument: '-gnatws' gnatmake: *** link failed. – notCoder Mar 23 '21 at 02:27
  • 1
    I found [this q&a](https://stackoverflow.com/questions/11530090/adding-a-new-entry-to-the-path-variable-in-zsh) quite confusing (as a long-term bash user, I might have snarked about zsh vs bash, but bash PATH settings and shell startup configuration are a black art too). Anyway, you could try `PATH=/Users/blessb/opt/GNAT/2020/bin:$PATH` or (zsh only) `path=(/Users/blessb/opt/GNAT/2020/bin $path)`. Fairly soon, you’re going to want to put something like that in one of your zsh startup files (perhaps `~/.zshrc`?) – Simon Wright Mar 23 '21 at 12:11
  • now it works! thanks! imma keep this question in case someone needs help – notCoder Mar 23 '21 at 15:50