安装Windows版C / GCC编译器

The first step in learning any programming language is to have the required software installed in the system. In this tutorial, we will learn how to install C/GCC compiler in Windows.

学习任何编程语言的第一步是在系统中安装必需的软件。 在本教程中,我们将学习如何在Windows中安装C / GCC编译器。

源代码编辑器 (Source Code Editors)

Although, you may choose any basic text editor such as notepad for writing and editing source code of C, we recommend choosing one of the editors below.

尽管您可以选择任何基本的文本编辑器(例如记事本)来编写和编辑C的源代码,但是我们建议选择以下一种编辑器。

  1. Notepad++ (Only for Windows)

    记事本++ (仅适用于Windows)
  2. Microsoft Visual Studio Code (For Windows and Linux)

    Microsoft Visual Studio代码 (适用于Windows和Linux)
  3. ATOM (For Windows and Linux)

    ATOM (适用于Windows和Linux)
  4. IDEs (Integrated Development Environment) such as Eclipse or Netbeans may be used but if you are a beginner in C programming, prefer using text editors mentioned above.

    可以使用诸如EclipseNetbeans之类的IDE(集成开发环境),但是如果您是C编程的初学者,则最好使用上面提到的文本编辑器。

安装Windows版C / GCC编译器 (Install C/GCC Compiler for Windows)

  • One of the preferred way to install C/GCC compiler is to use CodeBlocks. Just install it, launch it and start coding to keep things simple. In other words, CodeBlocks is a free C/C++ IDE that comes with the built-in compiler.

    安装C / GCC编译器的首选方法之一是使用CodeBlocks 。 只需安装它,启动它并开始编码就可以使事情变得简单。 换句话说,CodeBlocks是内置编译器随附的免费C / C ++ IDE。
  • Download codeblocks from www.codeblocks.org/downloads/binaries for your respective Operating System.

    www.codeblocks.org/downloads/binaries下载适用于您各自操作系统的代码块。
  • Windows users should choose download file which has “mingw” in its name, for example, codeblocks-17.12mingw-setup.exe.

    Windows用户应选择名称中带有“ mingw”的下载文件,例如codeblocks-17.12mingw-setup.exe
  • During installation, select Type of Install as “Minimal: Important plugins, important lexers” and make sure “MinGW Compiler Suite” is Checked. This will make sure that GCC compiler is also installed with the IDE.

    在安装过程中,将安装类型选择为“最小:重要的插件,重要的词法分析器” ,并确保选中“ MinGW Compiler Suite” 。 这将确保GCC编译器也随IDE一起安装。
  • 安装Windows版C / GCC编译器_第1张图片

    Codeblocks Install

    代码块安装


     


    安装Windows版C / GCC编译器_第2张图片

    Code Blocks Hello World

    代码块Hello World

为Windows设置PATH变量 (Setting up PATH Variable for Windows)

Once Codeblocks is installed, GCC compiler also gets installed with it. However, if we want to execute C programs from command prompt, we have to add its bin directory to the PATH variable.

一旦安装了Codeblocks,GCC编译器也会随之安装。 但是,如果要在命令提示符下执行C程序,则必须将其bin目录添加到PATH变量中。

  1. Go to installation Directory and copy the path of bin folder, e.g. “C:\Program Files (x86)\CodeBlocks\MinGW\bin

    转到安装目录并复制bin文件夹的路径,例如“ C:\ Program Files(x86)\ CodeBlocks \ MinGW \ bin
  2. Go to “Control Panel\System and Security\System”, Click “Advance System Settings” and then “Environment Variables”.

    转到“控制面板\系统和安全性\系统”,单击“高级系统设置”,然后单击“环境变量”。
  3. 安装Windows版C / GCC编译器_第3张图片

    Computer Properties

    电脑属性

  4. Find the Variable Name “Path” in User or System (if you are administrator) Variables and click on Edit.

    在用户或系统(如果您是管理员)变量中找到变量名“ Path”,然后单击“编辑”。
  • If you see a small popup, In “Variable value” box, go to end of text, put a semicolon “;” and paste the path of bin folder i.e. “C:\Program Files (x86)\CodeBlocks\MinGW\bin”

    如果您看到一个小的弹出窗口,请在“变量值”框中,转到文本末尾,并输入分号“;”。 并粘贴bin文件夹的路径,即“ C:\ Program Files(x86)\ CodeBlocks \ MinGW \ bin”
  • If you see a big popup (usually in windows 10) with the list of Path variables, click on “New” and paste the “bin” folder path.

    如果您看到带有Path变量列表的大弹出窗口(通常在Windows 10中),请单击“新建”,然后粘贴“ bin”文件夹路径。
  • Press OK on all opened popup windows.

    在所有打开的弹出窗口上按OK。
  • Open cmd and write “gcc” in it, press enter/return key.
    • If you see “gcc: fatal error: no input files compilation terminated.”, it means that GCC is successfully installed and you can exit the cmd.
    • In case you get the message “‘gcc’ is not recognized as an internal or external command”, follow steps correctly for installation and configuration of Path variable.

    打开cmd并在其中输入“ gcc”,然后按Enter /返回键。
    • 如果看到“ gcc:致命错误:没有输入文件编译终止。”,则表示GCC已成功安装,您可以退出cmd。
    • 如果收到消息“'gcc'未被识别为内部或外部命令”,请正确执行步骤以安装和配置Path变量。
  • That’s all for installing C/GCC compiler in Windows. We are ready now to explore coding features of C Programming.

    这就是在Windows中安装C / GCC编译器的全部内容。 我们现在准备探索C编程的编码功能。

    翻译自: https://www.journaldev.com/25757/c-compiler-windows-gcc

    你可能感兴趣的:(安装Windows版C / GCC编译器)