Skip to content

gjtiquia/hello-world-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hello World C++

A short documentation on how to setup, compile and run C++ properly on Linux.

Prerequisites

Have build-essential installed

sudo apt update && sudo apt install build-essential

This installs necessary packages such as g++ for compiling C++ source files.

Build - Using bash script

Run build.sh to compile main.cpp into a Linux executable main

Note: You will need a cross compiler to compile for other platforms, such as using mingw-w64 to compile for Windows. Another option would be to compile directly on the target machine.

Option 1:

bash build.sh

Option 2:

  • First give execute permissions
chmod +x build.sh
  • Then run the script
./build.sh

Build - Using g++

The bash script is written because i dun wanna type so many characters everytime i wanna build lol. Also prevents typos. I also dun needa remember all the commands if i just needa remember bash build.sh. Also allows the build step to change while i just needa remember one command.

But yeah, at least at this stage u can just build directly using

g++ main.cpp -o main

Execute

Run

./main

You should see the following output:

Hello World!

About

A short documentation on how to setup, compile and run C++ properly on Linux.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors