Eclipse下搭建一个C/C++的开发平台

来源:互联网 发布:js防水涂料怎么样 编辑:程序博客网 时间:2024/06/07 17:54

一直都想在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!!!  

0 0
原创粉丝点击