CC, GCC, g++, CC difference summary/bin/bash cc command not found

Source: Internet
Author: User

GCC is the C compiler; g++ is a C + + compiler; The Linux cc is typically a symbolic connection, and the GCC;GCC and g++ are all compilers of the gun (organization). And CC is generally a makefile inside a name, that is, macro definition, hey, because linux/unix are case sensitive system, this must be noted.

CC is the C Compiler of Unix systems, while GCC is the GNU Compiler Collection,gnu compiler suite. GCC was originally named the Gun C compiler because it could only handle the C language, but GCC quickly expanded to include many compilers (C, C + +, objective-c, Ada, Fortran, Java). Therefore, they are not the same, one is the old C compiler, one is the GNU compiler collection, the C compiler inside the GCC is much more powerful than CC, so there is no need to use CC.

The reason for not downloading CC is that CC is from an expensive UNIX system and CC is commercial software.

The CC under Linux is a GCC symbolic connection that can be viewed simply by $LS–L/USR/BIN/CC, which is the built-in variable of the Make program, which points to GCC by default. CC Symbolic links and variables exist in the meaning of the portability of the source code, you can easily use GCC to compile the old cc-compiled Unix software, and even makefile do not have to change, but also easy for Linux programs to compile under UNIX.

Myth One: gcc can only compile C code, g++ can only compile C + + code.

Both are possible, but please note:

(1) The suffix is. C, GCC treats it as a C program, and g++ as a C + + program; the suffix is. cpp, both of which are considered C + + programs, note that although C + + is a superset of C, there is a difference between the two requirements for syntax. C + + syntax rules are more rigorous.

(2) The compile phase, g++ will call GCC, for C + + code, the two are equivalent, but because the GCC command can not automatically and C + + program to use the library to join, so usually use g++ to complete the link, for the sake of unification, simply compile/link all use g++, which gives an illusion, As if the CPP program can only be used g++.

Myth Two: GCC does not define __cplusplus macros, and g++ will

In fact, this macro simply indicates that the compiler will interpret the code in C or C + + syntax, as described above, if the suffix is. c, and the GCC compiler is used, the macro is undefined, otherwise it is defined.

Myth Three: Compile only with GCC, link only with g++

Strictly speaking, this sentence is not wrong, but it confuses the concept, it should be said: Compile can be used gcc/g++, and links can be used g++ or gcc-lstdc++. Because GCC commands are not automatically joined to libraries that are used by C + + programs, you typically use g++ to complete joins. In the compilation phase, however, g++ automatically calls GCC, which is equivalent.

C + + compilers can certainly compile C's code, noting that in addition to C + + 's syntax extensions, compiling and linking C and C + + standard libraries is often different, as evidenced by the fact that GCC, not g++, compiles C + + programs.

Note: A symbolic link is a special type of file whose content is just a string. It may point to an existing file or may not point to anything. When you refer to a symbolic link in a command line or program, you actually enter the file it points to, provided that the file exists.


All the times you'll run into problems cc command not found, that is you want to do a soft link will cc point to GCC to compile makefile


CC, GCC, g++, CC difference summary/bin/bash cc command not found

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.