Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why are there duplicate C/C++ compilers (e.g g++, gcc)?

According to this answer, gcc and g++ have some functional differences. As confirmed by this script, the commands point to the exact same binary, effectively making them duplicates. Why is that so?

$ uname
Darwin
$ md5 `which cc c++ gcc g++ clang clang++`
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/cc
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/c++
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/gcc
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/g++
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/clang
fac4668657765c8dfe89d8995acfb5a2  /usr/bin/clang++

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The executable can determine the name it was called with by inspecting the first (or zeroth) command line argument passed to it. By convention it is the name of the executable and is passed by whatever program is invoking the compiler (typically e.g. a shell).

Although it is the same executable, it can then take different actions based on whether or not that value is gcc or g++.

Also, the files you are seeing are unlikely to be duplicate files. They are most likely just (soft or hard) links to the same file.


For the part that clang/clang++ and gcc/g++ seem to be the same, although they are completely different compilers, that is an Apple quirk. They link gcc and g++ to clang and clang++ for some reason, but in reality both refer to Apple clang, which is also different from upstream clang. It often causes confusion (at least for me).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading