我们可以到Eclipse官方主页上下载Eclipse的C/C++版本:
http://www.eclipse.org/downloads/
我们下载Eclipse IDE for C/C++ Developers版本,运行eclipse:
点击File → New → C Project并在弹出的选项窗口中选择Executable → Hello World ANSI C Project → Linux GCC并点击Finish按钮Eclipse将为我们自动生成相关示例代码:
/* ============================================================================ Name : C_Test.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio.h> #include <stdlib.h> int main(void) { puts("Hello World!!!"); /* prints Hello World!!! */ return EXIT_SUCCESS; }
执行Project → Build All编译代码:
11:39:57 **** Build of configuration Debug for project C_Test **** make all Building file: ../src/C_Test.c Invoking: GCC C Compiler gcc -O0 -g3 -Wall -c -MT"src/C_Test.d" -o "src/C_Test.o" "../src/C_Test.c" Finished building: ../src/C_Test.c Building target: C_Test Invoking: GCC C Linker gcc -o "C_Test" ./src/C_Test.o Finished building target: C_Test
编译成功,右键点击C_Test项目执行Run As → Local C/C++ Application选项,运行程序:
Hello World!!!
创建C++项目与创建C项目类似,只不过是选择C++ Project。编译并运行:
Hello World!!!
Copyright © 2015-2023 问渠网 辽ICP备15013245号