这篇文章主要介绍Eclipse下C/C++环境如何搭建,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
我们需要一个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的
C代码
#include ﹤stdio.h>
#include ﹤stdlib.h>
int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
return EXIT_SUCCESS;
}
控制台编译输出
Console代码
**** 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.c
gcc -oc.exe src\c.o
Build complete for project c
Time consumed: 14011 ms.
控制台结果输出
Console代码
!!!Hello World!!!
C++的
C++代码
#include ﹤iostream>
using namespace std;
int main() {
cout ﹤﹤ "!!!Hello World!!!" ﹤﹤ endl; // prints !!!Hello World!!!
return 0;
}
控制台编译输出
Console代码
**** 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.cpp
g++ -ocpp.exe src\cpp.o
Build complete for project cpp
Time consumed: 25452 ms.
控制台结果输出
Console代码
!!!Hello World!!!
以上是“Eclipse下C/C++环境如何搭建”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。