您的位置:首页 > 编程语言 > C语言/C++

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

2013-12-25 20:16 459 查看
一直都想在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!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: