Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship between gcc, g++, cygwin, and wingw?

I know for my class, I had to install cygwin to get my Netbeans IDE running, but I see options during setup for both g++ and gcc and I am not sure if they are the same thing or not, and where does wingw? is it another compiler, and if so why choose on over the other?

like image 779
Tanner Summers Avatar asked Jun 10 '15 18:06

Tanner Summers


2 Answers

g++ and gcc are the gnu C++ and C compiler respectively. They're really the same compiler with different flags though.

MinGW is "Minimalist Gnu for Windows". It's a port of the gnu compiler to run on Windows.

Cygwin is another port of the gnu compiler (and various other utilities) to Windows. More accurately (IMO, anyway), it's leaving the compiler/programs running on POSIX, and porting a POSIX layer to run on Windows.

As to choosing between them: if you're running Linux, you probably want ot just get a package of gcc/g++ for the distro you're using.

If you're running Windows, it'll depend on your intent. Cygwin works well for porting existing Linux/POSIX code to Windows. If, however, you plan to write code, and just want a compiler, I'd go for MinGW instead.

One other note: the MinGW at MinGW.org hasn't been updated in years. If you decide to go with MinGW, I'd advise getting it from nuwen.net instead (it's updated quite regularly).

like image 50
Jerry Coffin Avatar answered Sep 29 '22 22:09

Jerry Coffin


  1. gcc will compile: .c/.cpp files as C and C++ respectively.
  2. g++ will compile: .c/.cpp files but they will all be treated as C++ files.
  3. Also if you use g++ to link the object files it automatically links in the std C++ libraries (gcc does not do this).
  4. gcc compiling C files has less predefined macros.

For wingw, did you mean mingw? Because MinGW is for compatibility with Windows. MinGW uses GCC/G++, and MinGW is not a compiler, it's basically a stripped version of Cygwin that uses MS libs wherever possible.

like image 25
Olivier Poulin Avatar answered Sep 29 '22 20:09

Olivier Poulin