How to download c on windows 10

How to download c on windows 10

how to download c on windows 10

How to Download & Install GCC Compiler for C in Windows, Linux, Mac. Details: Last Updated: 29 October In this tutorial, we will learn to install C in. There are many compilers for C like Turbo C, GCC, Microsoft Visual Studio Express, Xcode, Pelles C and many more. When you will open the open link, the option to download turbo C++ will appear. Step A blue window will appear. It is huge to download and install (between 10 and 20 GB if I remember); It's a big pain to set up the first time; Building even a very simple project.

How to install the C language GCC compiler on Windows

On Linux, gcc is install by default and you can start to compile and execute C language code almost right away!

That&#;s not the case on Windows&#;

I have been struggling with how to do the same thing on Windows 10 for some time, but I finally succeeded

Here&#;s a video in which I explain the procedure:

Note: The procedure I describe here will not only allow you to install gcc, but also g++, gfortran, and many other useful tools that you usually only get in linux OS (like ls or grep)

1- What I want to teach you here

If you want a simple way to create programs based on C, C++, Fortran, etc&#; you will have to install a software with can compile the code you write into code that the machine understands

Such program is called a &#;compiler&#;

The most well know compiler for C language is the GNU compiler called GCC.

There are actually several compilers which go together like a suite:

  • for C++, you have the compiler  g++
  • for Fortran, the compiler is called gfortran

Why using the gcc compiler?

If you are on Windows, you probably heard about software such as visual studio from Microsoft which also you to write and compile C and C++ code as well.

That&#;s true, and it&#;s totally fine if you want to use it&#;

I am personally not such a big fan of Visual Studio because of the following reasons:

  • It is huge to download and install (between 10 and 20 GB if I remember)
  • It&#;s a big pain to set up the first time
  • Building even a very simple project takes much more time than it should

Because of that, I find that I kind of takes out the fun of programming and seeing immediately the result of what you did&#;

Now, for large pieces of software, visual studio is probably the way to go

2- How to use the gcc compiler?

Once installed on your machine, gcc is just a piece of cake to use to compile a simple c language code

Step 1: Write your c code

For example, let&#;s take this Hello World example

#include #include int main() { printf("Hello World!/n"); return 0; }

Step 2: Compile using gcc

Write the following line of code into your terminal:

gcc helloworld.c -o helloworld

This will generate an executable binary file called rushbrookrathbone.co.uk which can be used to run your code

Step 3: Execute your code

Just go into the directory where your executable is and run it by writing &#;rushbrookrathbone.co.uk&#;

2- The principle

Now that you understand how it can be easy to start with writing C code, let&#;s talk about the difficult part&#;

How to actually install gcc on Windows&#;

The reason it is easy to install compilers and other kind of open source software on linux is because you have a very powerful command line terminal called bash which handles the installation, uninstallation and upgrade of software using a software called &#;apt&#; on debian-based linux systems.

On Windows, if you want to have gcc (and the other compilers too), you have to download the source code and find a way to compile it&#;

For that, you will need to install first other software called pre-requisites which will also need to be compiled, etc&#;

You can spend several days trying to do that if you are really motivated

I will present you another way much simplier!

For that I will have to install a software called MSYS2, which is an &#;easy&#; way to give some linux feel to your Windows PC and able it to install programs almost as easily as in linux&#;

You will be able to install gcc just with one command line like this:

Excited?

Let&#;s go

3- Installing MSYS2 on your PC

What is MSYS2?
According to their website, MSYS2 is a software distribution and building platform for Windows

The Website: rushbrookrathbone.co.uk

Installing it is actually a peace of cake

Just download the correct installer and launch it with admin rights and you are good to go

Expected something more complex?

Sorry about that

Once you installed it, you will see 3 programs appear in your list of programs:

  • MSYS2 MinGW bit
  • MSYS2 MinGW bit
  • MSYS2 MSYS

Run the 3rd one MSYS2 MSYS to open a special command window in which you can input commands and start to install programs

The package management system which is equivalent to apt-get on linux is called pacman

When you install MSYS2 for the first time, you have to update pacman using the following command:

pacman -Syu

4- Installing GCC and other development tools with the pacman package management system

Then you can start to install gcc and other developer tools using pacman like this:

# Install make, autoconf, etc to C:\msys64\usr\bin pacman -S base-devel gcc vim cmake

This command will install first a set of development software included in a package called base-devel and then it will install gcc, vim and cmake

vim is optional, but always good to have ;-)
(You can also install emacs very easily in the same way)

In the package base-devel, you have 53 useful developement tools that can be installed:

# pacman -S base-devel 1) asciidoc 2) autoconf 3) autoconf 4) autogen 5) automake-wrapper 6) automake 7) automake 8) automake 9) automake 10) automake 11) automake 12) automake 13) automake 14) automake 15) automake 16) automake 17) bison 18) diffstat 19) diffutils 20) dos2unix 21) file 22) flex 23) gawk 24) gdb 25) gettext 26) gettext-devel 27) gperf 28) grep 29) groff 30) help2man 31) intltool 32) lemon 33) libtool 34) libunrar 35) libunrar-devel 36) m4 37) make 38) man-db 39) pacman 40) pactoys-git 41) patch 42) patchutils 43) perl 44) pkg-config 45) pkgfile 46) quilt 47) rcs 48) scons 49) sed 50) swig 51) texinfo 52) texinfo-tex 53) ttyrec # pacman -S gcc binutils isl mpc msys2-runtime-devel msys2-w32api-headersf9d msys2-w32api-runtimef9d windows-default-manifest gcc

5- Last Important Step: Add Executables to your Windows PATH

Now you are able to install all those packages easily, but how to access them through the normal windows command line?

For that, you have to add the two following directories to your PATH:

C:\msys64\mingw64\bin C:\msys64\usr\bin

To add anything to your PATH in Windows

1- Search &#;Advanced System Settings&#; in the search bar

2- Open the &#;environment variables&#; window, click on the PATH variable and click on &#;Edit&#;

3- Click on the &#;New&#; button and add the 2 following directories to your PATH

Important Note: This adds a lot of executables to your path which might conflict with other applications. The usr\bin\ directory contains the whole slew of executables listed above. There is a lot of unnecessary stuff in that directory.

4- Click on OK on all the windows and open a new Command Window and you will be able to use gcc into your windows command prompt!


That&#;s all for today, hope you understand better now how to install and use GCC and other linux tools on windows!

I will write new articles soon about how to develop simple programs in C.

Let me know through the comments if there is something special that you want to understand!

&#;Cyprien

 

 

 

 

PS: If you like what I write, subscribe to the newsletter and help me to spread the knowledge by sharing this article! We all win by learning from each other and making the engineering knowledge more accessible :-) THANK YOU!

Filed Under: Language C, Programming

Источник: [rushbrookrathbone.co.uk]

How to download c on windows 10

1 thoughts to “How to download c on windows 10”

Leave a Reply

Your email address will not be published. Required fields are marked *