Sign in to follow this  
mousetail

How to install GCC

Recommended Posts

mousetail    2540

I just got a new book about C and I am excited to learn the language that is used in most games, but the book says I need to install GCC. I found the GCC website, but it doesn't seem to have any download link anywhere. The only link it has leads to cygwin.com, and I don't see how that is related to C. Can anyone give me the link to download GCC for windows?

Share this post


Link to post
Share on other sites
JTippetts    12970
Cygwin and MinGW are both attempts at providing GCC plus standard libraries and build environments for Windows. Cygwin attempts to provide a POSIX environment, whereas MinGW does not. You can get modern builds of MinGW (which seems be more widely used than Cygwin these days) from the Mingw-w64 project.

Additionally, despite what the book says, you don't need to install GCC to use C/C++ on Windows. Microsoft provides their own solution in Visual Studio (link is to the free Express version.)

One final addendum: C is hardly used in games anymore; it tends to be the language of the lower-level kernel hackers. C++, however, is still widely used. C# also is making a strong showing, and if you go that route then Visual Studio is a good choice as it supports both C++ and C#.

Share this post


Link to post
Share on other sites

MinGW and MinGW-w64 are both mighty fine compilers which differ mainly in their implementations of the CRT and in support of newer features. MinGW-w64 has a much more up-to-date and complete API and is much more aggressively developed. The original MinGW, on the other hand, is more mature, and has a rather "conservative, safe" approach. You may find that one or the other new function isn't in the API, but usually you will not notice anything missing.

 

Note that MinGW-w64 is not necessarily only able to produce 64bit executables for 64bit Windows, even if the name may lead you to believe that. It produces 32-bit executables just fine (there exist 32bit-only builds and builds that can do both 32 and 64, depending on what commandline option you give to it).

 

The hardest bit is probably choosing which one to use, since there are so many versions and builds. It's a bit like being in a candy shop rolleyes.gif

 

I would recommend a 32bit-only gcc-4.8 build with SJLJ exceptions to start with (for example the TDM32 package). The generated executables run on any system, there's not much you can do wrong, and you do not have any obscure problems lurking (such as with DW2 exceptions). Version 4.8 has a good support of C++11 and is reasonably stable and bug-free. The generated code is up to par with the best available compilers.

 

Cygwin is something I wouldn't recommend, for two reasons. The less important reason is that it doesn't do what most people want. Most people actually don't want a complete POSIX emulation layer on top of Win32 (even more so as some things like fork do not map to Windows well at all!). The more important reason is, however, that the standard libraries you link with are under the GPL. Which means that any programs you write are necessarily under the GPL too. Free software is great, and if you never intend to write anything but free software, being bound to the GPL is no problem -- but most people will eventually discover that they have to eat and pay bills, too.

 

Using MinGW, on the other hand, the compiler is under the GPL (as well as the profiling lib), but the executables that come out are licensed any way you want. The standard library is technically under the GPL too, but there is a license clause that exempts you from the obligations.

Share this post


Link to post
Share on other sites

I just got a new book about C and I am excited to learn the language that is used in most games, but the book says I need to install GCC. I found the GCC website, but it doesn't seem to have any download link anywhere. The only link it has leads to cygwin.com, and I don't see how that is related to C. Can anyone give me the link to download GCC for windows?

 
I am happy to see you have found a strong interest in learning a new language.

 

One final addendum: C is hardly used in games anymore; it tends to be the language of the lower-level kernel hackers. C++, however, is still widely used. C# also is making a strong showing, and if you go that route then Visual Studio is a good choice as it supports both C++ and C#.

 
What JTippetts says is true. However, I feel it is still important to learn the C programming language as it gives you an appreciation, if not a better understanding of what goes on in higher level languages like C++ and C#.  Also, by understanding the differences between a low, mid and high level language, you have the needed awareness of what to be cautious about in programming high level applications (such as some games). C++ is, in my opinion, one of the most powerful languages around. This is essentially because C++ can be used in a C like low level paradigms or in a C# like high level paradigm. But with that power, comes the dangerous practice of mixing a low level and high level paradigm in a single application. This should be avoided. Not knowing the difference could get you in a lot of trouble, which recaps why I feel you should learn C.
 
Also, remember that since C++ is backwards compatible to C, you could simply install a C++ compiler, its libraries, and an IDE to support it while still learn C through use of it.
 

Or you can download Visual Studio, like JTippets suggested, which is probably the better option! Note: By "Express version" of Visual Studio, that doesn't mean it's limited or useless or slimmed down. It's fully functional with everything you need - including if you later want to sell your programs commercially.

 
What Servant of the Lord refers to is also correct and vitally important. As novice programmers, many people tend to not realize the vital importance of understanding the complexity behind copy right laws, and where copy left laws associate. It is important to understand the clear definition of what GNU means, and how it applies to anything you create. For more reading, see here: http://en.wikipedia.org/wiki/GNU_General_Public_License
 
Now, all methods of setting up your IDE listed from Servant of the Lord and JTippetts are correct and are very useful. But both methods will also come with the proprietary development of Windows programming (some exceptions with Qt and Cygwin). Assuming that you one day wish to expand to other operating systems, another option for you is to use the Eclipse IDE. For right now, I would avoid using it in Windows as it requires some greater knowledge in configuring it with a C++ compiler. However, when you do feel ready, it can be setup to use MinGW, Cygwin, Linux/UNIX or the same compiler used by Visual Studios! And because Eclipse is not GNU licensed, you could also program on a Mac and still sell the game!

 

If you want to get a feel for how it works in a different OS environment, you could do it by simply following the below steps:

 

1.Download/Install the Oracle VM here: https://www.virtualbox.org/

2.Download CentOS here: http://www.centos.org/

3.Run Oracle VM and install the CentOS in a virtual environment. Here's a tutorial on installing CentOS:

http://www.tecmint.com/centos-6-3-step-by-step-installation-guide-with-screenshots/

NOTE: When installing CentOS, choose the prepackage option (step 19 on the tutorial) of a Software Development Workstation.

4.Run the OS, Log in, and start the Eclipse IDE (The Linux C/C++ compiler is already configured for you).

5.Follow the steps normally taken in creating a C++ project, and start coding away. 

NOTE: 3D programming may require additional Linux RPMs and may not run properly in a VM environment. Additionally, 3D programming frameworks associating to DirectX and Direct3D will not work on Linux without WINE bindings. Finally, when you develop using Eclipse on a Mac, you'll be using a different compiler, which may require a manual configuration in the Eclipse IDE.

 

To make full use of my recommendation, learn how to use preprocessor directives, and make your code very efficient for cross-platform execution (an advantage of learning C). The preprocessor directives can judgement whether to use Direct3D or OpenGL based on which compiler is detected. In essence, a solid application will only need to be compiled multiple times between different compilers generating multiple executables. Thus, all you would do is create a script that decides which executable to run based on which operating system is detected and you have a cross-platform package with multiple executable that were compiled with absolutely no coding differences.

Edited by Subtle_Wonders

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this