Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find gcc version on mac

Tags:

c

macos

gcc

I am using OS 10.9 on mac machine. I want to know the version of gcc I am using. So I tried gcc --version on terminal and it results :

$ gcc --version Configured with: --prefix=/Applications/Xcode5-DP.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode5-DP.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.1.58) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix 

Here in output, there is no detail related to gcc but clang is there. I am confused whether gcc command executes clang or gcc(gnu).

like image 379
subhash kumar singh Avatar asked Dec 05 '13 21:12

subhash kumar singh


People also ask

How do I know if gcc is installed on my Mac?

The name of the C compiler (that was installed along with the command line tools) is gcc. To check that this is now successfully installed, enter "gcc --version" at the prompt.

Where is gcc located in Mac?

The gcc application will be installed by default in /usr/local/bin. Personally, I use Apple's clang/clang++ compilation tools rather than deal with GNU gcc. These instructions will give you a C compiler environment.

How do I know which gcc version I have?

gcc --version will tell you the version of the gcc executable in your path. rpm -q libstdc++-devel will tell you the version of the package that owns the C++ standard library headers. rpm --verify libstdc++-devel will check that you haven't messed up the C++ headers by replacing them with something else.


2 Answers

You seem to not actually have gcc on your path. As of recent versions of Xcode, it installs a "gcc" that is instead a link to Clang.

like image 120
danfuzz Avatar answered Oct 01 '22 07:10

danfuzz


gcc -dumpversion | cut -f1 -d. 

-dumpversion Print the compiler version (for example, 3.0) — and don't do anything else.

The same works for following compilers/aliases:

cc -dumpversion g++ -dumpversion clang -dumpversion tcc -dumpversion 

Be careful with automate parsing the GCC output:

  • Output of --version might be localized (e.g. to Russian, Chinese, etc.)
  • GCC might be built with option --with-gcc-major-version-only. And some distros (e.g. Fedora) are already using that
  • GCC might be built with option --with-pkgversion. And --version output will contain something like Android (5220042 based on r346389c) clang version 8.0.7 (it's real version string)
like image 25
serghei Avatar answered Oct 01 '22 08:10

serghei