C programming language compiler Environment construction refers to the installation of compiler or Integrated Development Environment (IDE) installation, configuration and debugging, until the C language source code can be executed normally process. If you want to set up your C environment, you need to make sure you have two software programs available on your computer, a text editor and a C compiler. C compilers are widely used in various operating systems, such as Unix, Windows, Linux, Mac OS X, and so on.

! [](https://upload-images.jianshu.io/upload_images/24563956-7b2fee1ec38c7caf.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

The choice of development environment seems to tell us that if we want to do good work, we must first sharpen our tools.

Text editor

This will be used to enter your program. Text editors include Windows Notepad, OS Edit Command, Brief, Epsilon, EMACS, and Vim /vi.

The name and version of a text editor may differ on different operating systems. For example, Notepad is commonly used on Windows operating systems and Vim /vi is available on Linux/UNIX operating systems.

Files created through an editor are often referred to as source files, which contain the program source code. Source files for C programs usually use the extension **.c**.

Before you start programming, make sure you have a text editor and enough experience to write a computer program, then save it in a file, compile and execute it.

! [](https://upload-images.jianshu.io/upload_images/24563956-a2f3ac0f179a9f1f.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

The C compiler

The source code written in a source file is a human-readable source. It needs to be “compiled” into machine language so that the CPU can execute the program as given.

C compilers are used to compile source code into a final executable program. It is assumed that you already have a basic understanding of programming language compilers.

The most commonly available compiler for free is the GNU C/C++ compiler, or if you are using HP or Solaris, the compiler on your respective operating system.

The following sections guide you through installing the GNU C/C++ compiler on different operating systems. C/C++ is mentioned here, mainly because the GNU GCC compiler is suitable for BOTH C and C++ programming languages.

! [](https://upload-images.jianshu.io/upload_images/24563956-cabccf2384a7f6b0.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

How do I use a text editor

C program development when we use development software VC++6.0, visual studio and so on, but for some simple programs we prefer notepad or notepad++ and other convenient tools for editing, editing and then running through the CMD window, but we have to give it an environment, So that it can be compiled using CMD to run, here today I will introduce to you, how to build their own C language development environment step by step from scratch.

First of all, we have to have VC in our computer. If not, we can download VC++, Visual Studio, and other software. After downloading, we can find their directories. At this point, let’s copy its file path.

! [](https://upload-images.jianshu.io/upload_images/24563956-8e35fd47b0d9eff8? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

Go back to the desktop, right click on the properties of the computer, and we’ll find the environment variable in advanced, and we’ll find the environment variable Path, because then we can compile C files in any folder. Let’s paste the paths we just copied after the Path variable, separated by a semicolon, and click OK.

! [](https://upload-images.jianshu.io/upload_images/24563956-df154784d7508a1f.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

After completing the above steps, we can not compile, because the library files and header files required during compilation have not been set as environment variables, so we can not compile again, so we need to set Lib and Include folders as environment variables, we find these two folders, copy their paths, Then create two new variables for the environment variables of the computer properties, respectively LIB and INCLUDE, with their paths.

! [](https://upload-images.jianshu.io/upload_images/24563956-46791e269cb60467.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

After completing the above, click OK, run CMD, type CL, and press Enter. If its version number appears, the setup is successful. Let’s write a classic HelloWord program and run it.

! [](https://upload-images.jianshu.io/upload_images/24563956-ed9f49ef82d1a825? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

To save, change the extension name to C and click Save. Next open CMD again

! [](https://upload-images.jianshu.io/upload_images/24563956-346c6cc0e1fb4b71.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

In CMD, type cl helloword. c to execute the compilation, notice that cl and your filename have Spaces directly, then wait for the compilation to succeed and type helloword. exe again to execute the compiled file. This is how c is compiled using CMD.

! [](https://upload-images.jianshu.io/upload_images/24563956-209e9f2028638f6e.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

Matters needing attention:

Note that semicolons are added between Path environment variables, and pay attention to backup. In case it gets lost.

How do I use the Visual Studio compiler?

1. Download and install Visual Studio Community 2015.

2. Open Visual Studio Community

3. Click File -> New -> Project

! [](https://upload-images.jianshu.io/upload_images/24563956-e686defd7bb09eae? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

Select Templates -> Visual C++ -> Win32 Console Application from the left list and set the project name to MyFirstProgram.

! [](https://upload-images.jianshu.io/upload_images/24563956-acfa82b94bd8621b? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

5. Click OK.

6. Click Next in the following window

! [](https://upload-images.jianshu.io/upload_images/24563956-e145380758f1fa21? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

7. In the window that pops up, select the Empty Project option and click Finish:

8, right-click Source File and click Add –> New Item… :

! [](https://upload-images.jianshu.io/upload_images/24563956-81d4023968f70149? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

9, select C++ File and set the File name to main. CPP, then click Add:

! [](https://upload-images.jianshu.io/upload_images/24563956-91734bb3bd325081? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

10, Copy the following code into main. CPP:

#include

int main()

{

std::cout << “Hello World! \n”;

return 0;

}

The interface is as follows:

! [](https://upload-images.jianshu.io/upload_images/24563956-8fee082dfa8aff47? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

11. Click Debug -> Start Without Debugging (or CTRL + F5) on the menu:

! [](https://upload-images.jianshu.io/upload_images/24563956-8fa631b0509c20dc? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

12. After the above operation, you should see the following output:

! [](https://upload-images.jianshu.io/upload_images/24563956-9f9d0ff7b3a78f53? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
! [](https://upload-images.jianshu.io/upload_images/24563956-90a54aba046db4d1.gif? imageMogr2/auto-orient/strip)

The above is the use of C and C++ text editor and VS compiler details, if you want to better improve your programming ability, learn C/C++ programming knowledge! Then you are in luck

Join C /C++ penguin and share some interesting things you may not know.