代码之家  ›  专栏  ›  技术社区  ›  Jonas

如何用Eclipse和CDT编译和运行MinGW C++?

  •  16
  • Jonas  · 技术社区  · 14 年前

    我想用Eclipse和Windows在Windows上做一些C++开发 CDT MinGW 现在我在Eclipse中写了一个简单的“Hello World”。

    你好,cpp

    #include <iostream>
    using namespace std;
    int main()
    {
        cout << "Hello World" << endl;
        return 0;
    }
    

    在Eclipse中使用CDT插件和MinGW编译器。如何编译程序?如何在Eclipse中测试运行该程序?

    4 回复  |  直到 14 年前
        1
  •  11
  •   Jonas    14 年前
        2
  •  3
  •   JFXNerd    12 年前

    下面是在Eclipse上安装MinGW的另一个好资源: http://chrismwright.wordpress.com/2012/10/13/installing-eclipse-for-cc-and-mingw/

    基本上是一个循序渐进的安装过程,包括最后的Hello World示例。。。

        3
  •  3
  •   AndriiL    8 年前

    在浏览了许多帖子和文章之后,我找到了一个解决方案。 使用C++开发工具92.1.201704050430和MinGW在Eclipse Neon 3上发布Windows 10 X64测试(4.63.)

    1. 下载MinGW。任何发行版都可以工作。我用了 distro 推荐日期 http://isocpp.org/
    2. C:\MinGW (实际上 C:\ ,因为存档包含文件夹 MinGW
    3. 人民币兑 This PC -> Properties -> Additional system settings ->选项卡 Advanced ->按钮 Environment variables
    4. System variables 点击 New . 名称变量 MINGW_HOME C: \MinGW公司 然后 OK
    5. 查找变量 Path 在桌子上选择 Edit
    6. 在新窗口中单击 和类型 %MINGW_HOME%\bin\
    7. 单击“确认操作” 好 啊 在打开的窗口中
    8. 您可以通过键入命令行来检查新工具的可用性 g++ --version 你应该看看

    g++ (GCC) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    Eclipse CDT配置

    1. 安装 Eclipse with CDT 或者只是加上 CDT 到现有的Eclipse安装
    2. 转到已安装MinGW的文件夹( C:\MinGW\bin\ ). 复制文件 gcc.exe
    3. 将复制的文件重命名为 mingw32-gcc.exe (你应该有两个文件 mingw32-gcc.exe 在里面 \MinGW\bin\ )
    4. C\C++ 观点
    5. Window -> Preferences -> -> Build -> Environment
    6. Add 和类型 PATH 作为名称并单击 Variables 路径 . 确认 Ok .
    7. 路径 通过单击 Select 然后 好 啊 .
    8. 重新启动Eclipse

    现在你应该可以编译Hello World程序了。只需选择 新的 -> C++ Project

        4
  •  0
  •   Harshith Rai    6 年前

    只需添加 MinGW 到系统路径(AndriiL文章中的系统配置部分)就足够了。名为 PATH ${PATH} 因为价值将自动添加到 Window -> Preferences -> C\C++ -> Build -> Environment 你可以看到 MinGW GCC 作为项目向导中的工具链选项。如果没有路径变量,Eclipse CDT可能不会在OS中加载最近的系统路径更改(单击 Select... 然后选择 Path variable

    推荐文章