16

I somehow lost the man pages for gcc and g++. I'm not sure where/what to look for. I'm pretty sure the man pages used to work some time ago. It also works on my Mac at work where I use roughly the same setup. Could it be a problem with brew? Or is it a bug in the XCode Command Line Tools?

Update: I just tried to re-install the XCode Command Line Tools. No luck.

~
✓  man gcc
No manual entry for gcc

~
✗  which gcc
/usr/bin/gcc

~
✓  gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Jan Deinhard
  • 19,645
  • 24
  • 81
  • 137

5 Answers5

15

gcc isn't installed anymore by Xcode, it really installs clang and calls it gcc

usxxplayegm1:~ grady$ which gcc
/usr/bin/gcc

usxxplayegm1:~ grady$ /usr/bin/gcc --version

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.2
Thread model: posix

you need man clang

I thought it was a symlink, but ls -l doesn't list it as a symlink, so either it is a hard link or some other sort of trickery.

Grady Player
  • 14,399
  • 2
  • 48
  • 76
  • 2
    @PaulJ.Lucas after Xcode is installed it should just be available... but you can also reference the file directly.... `man /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man/man1/clang.1` – Grady Player Nov 29 '14 at 15:46
  • Thanks! I wasn't finding it because that path wasn't in my `MANPATH`. It's not listed in either `/etc/manpaths` or in `/etc/manpaths.d`. So how does your system find it? Or do you just explicitly add it to your `MANPATH` yourself? – Paul J. Lucas Dec 01 '14 at 18:50
  • if you either install the command line tools (older versions), or just install and use the newer Xcode it *should* be automagical – Grady Player Dec 01 '14 at 19:00
  • I've figured out that if `MANPATH` is unset, then it works. Obviously if one explicitly sets `MANPATH` in one's `.profile` (and it doesn't include the path leading to `clang.1`) then it won't work. Do you know how `man` is told what paths to use when `MANPATH` is unset? – Paul J. Lucas Dec 01 '14 at 19:12
  • @PaulJ.Lucas read 'man man' section **SEARCH PATH FOR MANUAL PAGES** – Grady Player Dec 01 '14 at 19:16
  • I read it and looked at `/etc/man.conf`. Nothing is says explains how it finds a man page buried deep inside the Xcode bundle; yet it does. – Paul J. Lucas Dec 01 '14 at 20:34
  • 2
    yeah it looks like it is hard coded magic... try `man -d clang` – Grady Player Dec 01 '14 at 20:58
5

This may be old and doesn't quite answers your concrete question, but I found myself in the same problem with Kali Linux and I solved it with this command, maybe is useful for someone:

apt install gcc-doc
kelov
  • 63
  • 1
  • 4
1

Look at how you set MANPATH in your .profile. Instead of, e.g.,

export MANPATH=/opt/local/man:/usr/local/man

you should do

export MANPATH="/opt/local/man:/usr/local/man:$MANPATH"

And then (breathe) open a new Terminal window.

This way your .profile isn't wiping out (or reflecting an old version of) the system's way of setting MANPATH, which is modified when you install (or reinstall) Xcode.

FutureNerd
  • 769
  • 7
  • 9
1

I use High Sierra with g++ 7.2 port. Setting MANPATH environment to /opt/local/man (or to /opt/local/man/man1 where g++.gz is found) did not work. So, after ensuring that the soft link g++.gz points to g++-mp-7.1.gz (there was not a g++-mp-7.2.gz in the man1 directory though g++7.2 is my version), I always use the command:

man /opt/local/share/man/man1/g++.gz

that never fails. You can store an alias for this in your .profile, if you are frequently using the man command for g++.

Seshadri R
  • 1,192
  • 14
  • 24
0

For anyone who stumbles upon this currently (like I did), I found that I needed to locate my version of gcc (which I had installed with brew). This is annoying when gcc --version gives the clang version instead! To find the correct gcc version, run

$ ls /usr/local/opt/gcc/bin | grep gcc
gcc-10
gcc-ar-10
gcc-nm-10
...

So I had gcc-10. Whenever you wish to use gcc just replace it with gcc-10, e.g. man gcc-10. Of course you could write an alias for gcc to gcc-10, but this probably is not a great idea, as Xcode seems to rely on the gcc --> clang (hard?) link.

Chris
  • 41
  • 6