Eclipse 创建 Hello World 工程

发布于:2024-02-19 ⋅ 阅读:(44) ⋅ 点赞:(0)

Eclipse 创建 Hello World 工程

Download and install the Eclipse IDE.

1. Hello World

Eclipse -> double click -> Launch

在这里插入图片描述

单击蓝色方框 (右上角)

在这里插入图片描述

最大化 IDE

在这里插入图片描述

File -> New -> C Project -> Finish

在这里插入图片描述

Project name:工程名

Use default location:勾选此项,项目默认创建在 eclipse workspace 目录下。如果不勾选,那么在 Location 处可以选择项目位置。如果已经有了项目目录,想要直接把 eclipse 工程文件创建在自己的代码目录里,请选择后者。

Project type:工程类型

GNU Autotools:该类项目默认选择用 GUN Autotools 进行构建管理,eclipse 不会为其自动生成 makefile。在项目的属性对话框里面将会有一个对 GNU Autotools 的配置页面。

Executable:可执行项目,eclipse 默认会为其生成 makefile。该类工程允许在工程属性对话框里面配置各种编译链接参数,这些配置的修改都会决定自动生成的 makefile 内容。Empty Project 和 Hello World ANSI C Project 的区别在于后者会自动为项目创建一个 src 目录以及一个实现了输出 “hello world” 的 c 文件。

Makefile Project:该类工程默认用户使用自定义的 makefile,不会为项目自动创建 makefile。该类工程的工程属性对话框里面默认不可以对编译、链接参数进行配置,它会使用用户 makefile 中的参数进行项目解析。

Shared Library:共享库工程。默认项目的构建结果为共享库,在工程属性里面会有对共享库的各种构建配置选项。

Static Library:静态库工程。默认项目的构建结果为静态库,在工程属性里面会有对静态库的各种构建配置选项。

Toolchains:工具链。该对话框里 eclipse 会自动识别系统安装的工具链。如果你安装了 Cygwin GCC 或者 MinGW GCC 的工具链,也会显示在这里以供选择。如果使用 Linux 下默认的工具链,则选择 Linux GCC。如果选择 Cross GCC,说明项目是交叉编译,那么工程属性对话框里面需要进行交叉工具链的各种配置。

/*
 ============================================================================
 Name        : hello_world.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 Project

Run As -> 1 Local C/C++ Application

Console

!!!Hello World!!!
/*
 ============================================================================
 Name        : hello_world.c
 Author      : Yongqiang Cheng
 Version     : Version 1.0.0
 Copyright   : Copyright (c) 2019 Yongqiang Cheng
 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;
}

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到