1

I'm running macOS Mojave (10.14.6) and carried out the following instructions: Page 1 Page 2 Page 3

I've followed the instructions without any problems so far but when I enter "type gcc" into the terminal like the book asks on page 3, I get the following:

$ type gcc
gcc is /usr/bin/gcc

The book makes it clear that if the the bash shell is locating gcc from a different directory, the PATH is not set correctly. So how do I fix the PATH so that the bash shell locates gcc at the desired directory (“/opt/gcc-arm/bin/gcc”)?

Page 3 (Continued)

2 Answers 2

1

This is mentioned in step 10 of your own instructions:

  1. Now, exit root and return to your developer session. In that session, add the compiler’s bin directory to your PATH:

    $ export PATH="/opt/gcc-arm/bin:$PATH"

Note that your instructions also show a different name for the compiler – instead of "gcc", it is named "arm-none-eabi-gcc". (The last page says that if you obtain the compiler from other sources, it may be named just "gcc".)

So try type arm-none-eabi-gcc first. If the above change doesn't work, you should actually look inside /opt/gcc-arm/bin and check what executables are present.

Finally, if you're using bash, the type command will use its internal cache of previously found paths; you might need to run hash -r to clear this cache.

2
  • 1
    Thanks for the quick response. I had tried everything you suggested already (good to know I was on the right track!) - except for the hash -r command. Tried everything again after the cache was cleared and still got "gcc is /usr/bin/gcc". I checked inside /opt/gcc-arm/bin and found arm-none-eabi-gcc but not gcc. The instructions actually tell you to also enter "type arm-none-eabi-gcc" later (see "Page 3 (Continued)" from my recent edit). So why would the instructions ask me to enter "type gcc" if the commands from the previous instructions never created gcc in the /opt/gcc-arm/bin folder?
    – Sean Dever
    Aug 23, 2019 at 8:11
  • Never mind, I reread the instructions. It clearly says “If you see the file name gcc instead of arm-none-eabi-gcc, you’ll need to invoke it as simply gcc. In this case ....” Apologies for wasting time.
    – Sean Dever
    Aug 23, 2019 at 8:19
0

You can do it in home directory of your user using .bash_profile file. Add line export PATH=$PATH:/<path_to_your_gcc>

Hope it will help.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .