HOW TO WRITE, COMPILE AND RUN C++ CODE ON LINUX KALI

Samuel Kingsley
2 min readApr 24, 2022

I published this post on my blog in 2015, but since my blog is not popular, I decided to publish it here on medium so that more readers can have access to it.

C++ on kali linux

This article is for hackers who want to develop a c++ program on Kali
Linux without having to install any additional software.

While some would tell you that you need to install an additional
software or a compiler in order to develop a simple program in c++ on
Kali Linux, I am going to show you how to develop a c++ program on
this distro right out of box.

Your Linux Kali comes pre-installed with a c++ compiler called g++ so
we are going to write a C++ hello word code and compile it with this
compiler.

Before we get started, first open up terminal and run to verify if
this compiler is installed on you machine: g++ -v
if the compiler is pre-installed, you should get the version
information of the compiler, otherwise, you should get an error.

Now let’s jump right in.
In your terminal window, type in: nano MyCpp.cpp to create a c++ file
and lunch it in nano editor for editing.

When nano opens, type in the following c++ code and press Ctrl+x then
y and then Return/Enter key.

//The code
#include <iostream>
using namespace std;

int main(void)
{
cout<<”Hello world”;
return 0;
}

Once the above is done, type g++ MyCpp.cpp to compile the code and if
everything goes well, prompt should be returned without any message.
Note that another file named a.out was created in that directory where
you compiled you program, well that looks like the output or binary of
you program. To run the just created program, just type ./a.out and
your c++ little software will run with no issues.

That was easy, wasn’t it? Thanks for reading.

--

--