An open API service indexing awesome lists of open source software.

https://github.com/appleboiy/helloworld.cpp

Hello world program in C++
https://github.com/appleboiy/helloworld.cpp

Last synced: 9 months ago
JSON representation

Hello world program in C++

Awesome Lists containing this project

README

          

# Hello, World! - C++





C++ Logo



Logo endorsed by the C++ standards committee


## Description

`C++` is a general-purpose programming language created by [Bjarne Stroustrup](https://en.wikipedia.org/wiki/Bjarne_Stroustrup) as an extension of the [C programming language](), or "C with Classes". The language has expanded significantly over time, and modern `C++` has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

## The `CMakeLists.txt` File[^1]

For a simple `C++` project (e.g., a "Hello, World!" program), the `CMakeLists.txt`[^1] file is typically very simple.

```txt
.
├── CMakeLists.txt
└── src
└── hello_world.cpp
```

**_CMakeLists.txt_**[^1]

```cmake
# Set the minimum version of CMake that can be used
cmake_minimum_required(VERSION 3.5)

# Set the project name
project(HelloWorld)

# Add an executable
add_executable(hello_world src/hello_world.cpp)
```

### Running the Program

To run the program, follow these steps:

1. Run `CMake` to configure the project:

```bash
cmake .
```

2. Build the project:

```bash
make
```

4. Run the program:

```bash
./hello_world
```

**To clean the project:**

```bash
make clean-all
```

[^1]: `CMakeLists.txt` is a simple text file that is used to configure a project that is built using the `CMake` build system. The `CMakeLists.txt` file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both). The `CMakeLists.txt` file must be present in the root directory of the project.