Eclipse下C/C++环境搭建
来源:互联网 发布:近几年石油开采量数据 编辑:程序博客网 时间:2024/05/22 12:00
一直都想在Eclipse下搭建一个C/C++的开发平台,却一直未能如愿。最近,终于成功了,其实很简单。
安装
设置环境变量
新建C项目
新建C++项目
来段HelloWorld
C的
控制台编译输出
控制台结果输出
C++的
控制台编译输出
控制台结果输出
MinGW-5.1.4.exe、gdb-5.2.1-1.exe文件我已经放到了附件中,大家可以直接下载。
- 我们需要一个cdt,这个可以在Eclipse官网下载。
- 我们需要MinGW——C/C++编译平台,下载后需要安装,同时选中g++、MinGW Make,同时设置环境变量,将%MinGW_HOME%/bin设置到PATH中,然后我们可以通过命令行敲击gcc,看是否有效果。
- 我们需要gdb——C/C++调试平台,下载后安装,默认到MinGW_HOME就行。
- 我们开启eclipse编译一个C/C++工程,右键可以运行,调试。
安装
设置环境变量
新建C项目
新建C++项目
来段HelloWorld
C的
#include <stdio.h>#include <stdlib.h>int main(void) {puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */return EXIT_SUCCESS;}
控制台编译输出
**** Build of configuration Debug for project c ******** Internal Builder is used for build ****gcc -O0 -g3 -Wall -c -fmessage-length=0 -osrc/c.o ../src/c.cgcc -oc.exe src/c.oBuild complete for project cTime consumed: 14011 ms.
控制台结果输出
!!!Hello World!!!
C++的
#include <iostream>using namespace std;int main() {cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!return 0;}
控制台编译输出
**** Build of configuration Debug for project cpp ******** Internal Builder is used for build ****g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc/cpp.o ../src/cpp.cppg++ -ocpp.exe src/cpp.oBuild complete for project cppTime consumed: 25452 ms.
控制台结果输出
!!!Hello World!!!
MinGW-5.1.4.exe、gdb-5.2.1-1.exe文件我已经放到了附件中,大家可以直接下载。