PrevUpHomeNext

day-01: How to compile c++


day-01: how to compile cpp: Hello World!

Hello World: How to compile cpp/c++ code.

How to build and run cpp code

Get cpp compiler

c++ compiler

There are many c++ compiler nowadays, the most popular and complete c++ compilers are:

You can go to their homepage and find how to download and install.

c++ compiler

And also, c++ sycl compiler can build standard c++ code too:

Use a code editor

You can write c++ code with most text editors, there are many text editors you can find on Internet, such as notepad, featherpad, cpeditor, vim, kakoune, emacs, visual studio ide, etc.

I am using kakoune kak editor, it is a good c++ code editor. (Home)

Hello World! Build your first cpp code and run your generated program!

c++ code

First, copy the following c++ code to a text editor, and save it as prog.cpp :

#include <iostream>

int main()
{
	std::cout << "Hello World! This is a c++ program!" << std::endl;
}

Build it with gcc c++ compiler

g++ prog.cpp -std=c++23 -o prog

The generated program of the code is prog .

Run the program

Run:

./prog

Output:

Hello World! This is a c++ program!

Last

In this article of this day, all you have to do is downloading compiler, installing compiler, copying above c++ code, building and running. I guess you can finish them within 10 minutes, you can continue to learn day-02 article in the same day now. So then, day-01 and day-02 articles can be finished in one day.

Written on Aug 03, 2024

Back to index

Index

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ===================================
  #  The c++ programming language.  #
  #                                 #
  #  Join c++ Discord: yZcauUAUyC   #
  #  Deck                           #
  ===================================

Home: cppfx.xyz

K


PrevUpHomeNext