Eclipse下C/C++环境搭建

一直都想在Eclipse下搭建一个C/C++的开发平台,却一直未能如愿。最近,终于成功了,其实很简单。  

  1. 我们需要一个cdt,这个可以在Eclipse官网下载。
  2. 我们需要MinGW——C/C++编译平台,下载后需要安装,同时选中g++、MinGW Make,同时设置环境变量,将%MinGW_HOME%\bin设置到PATH中,然后我们可以通过命令行敲击gcc,看是否有效果。
  3. 我们需要gdb——C/C++调试平台,下载后安装,默认到MinGW_HOME就行。
  4. 我们开启eclipse编译一个C/C++工程,右键可以运行,调试。


安装 
 

设置环境变量 
 
 


新建C项目 
 

新建C++项目 

 

来段HelloWorld 
C的 
C代码   收藏代码
  1. #include <stdio.h>  
  2. #include <stdlib.h>  
  3.   
  4. int main(void) {  
  5.     puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */  
  6.     return EXIT_SUCCESS;  
  7. }  


控制台编译输出 
Console代码   收藏代码
  1. **** Build of configuration Debug for project c ****  
  2.   
  3. **** Internal Builder is used for build               ****  
  4. gcc -O0 -g3 -Wall -c -fmessage-length=0 -osrc\c.o ..\src\c.c  
  5. gcc -oc.exe src\c.o  
  6. Build complete for project c  
  7. Time consumed: 14011  ms.     


控制台结果输出 
Console代码   收藏代码
  1. !!!Hello World!!!  


C++的 
C++代码   收藏代码
  1. #include <iostream>  
  2.   
  3. using namespace std;  
  4.   
  5. int main() {  
  6.     cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!  
  7.   
  8.     return 0;  
  9. }  


控制台编译输出 
Console代码   收藏代码
  1. **** Build of configuration Debug for project cpp ****  
  2.   
  3. **** Internal Builder is used for build               ****  
  4. g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\cpp.o ..\src\cpp.cpp  
  5. g++ -ocpp.exe src\cpp.o  
  6. Build complete for project cpp  
  7. Time consumed: 25452  ms.    


控制台结果输出 
Console代码   收藏代码
  1. !!!Hello World!!!  

MinGW-5.1.4.exe、gdb-5.2.1-1.exe文件 在csdn下载资源中搜索 wop_cpp1987

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值