Skip to main content

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



Developing a C++ Program on Kali Linux Without Installing Additional Software

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

Some might say you need to install a separate compiler or extra tools to write and run a simple C++ program on Kali Linux. However, I’ll show you how to do it right out of the box.

Pre-installed C++ Compiler in Kali Linux

Kali Linux comes with a pre-installed C++ compiler called g++. We will use this to write and compile a basic "Hello, World!" program.

Step 1: Check if g++ is Installed

Open your terminal and run the following command:

g++ -v

If the compiler is installed, you should see version details. If not, you will get an error message.

Step 2: Create a C++ File

In your terminal, type:

nano MyCpp.cpp

This will create a C++ file and open it in the Nano editor.

Step 3: Write the C++ Code

Once Nano opens, enter the following C++ code:


#include <iostream>
using namespace std;

int main() {
    cout << "Hello, World!";
    return 0;
}

Press Ctrl + X, then Y, and hit Enter to save and exit.

Step 4: Compile the Code

Run the following command in your terminal:

g++ MyCpp.cpp

If everything goes well, the command will return to the prompt without any message. You’ll notice that a new file named a.out has been created in the same directory. This is the compiled binary of your program.

Step 5: Run Your C++ Program

To execute your newly created program, type:

./a.out

Your program should display:

Hello, World!

Conclusion

That was easy, wasn’t it? Now you can start building more complex programs using C++ on Kali Linux. Thanks for reading!

Comments

Post a Comment

Popular posts from this blog

HOW TO INSTALL BLOGENGINE.NET WITH VISUAL STUDIO.

Yes there are lots of article on the internet that already describes how to do this, but that wont stop me from sharing my own idea on how I got mine rocking with visual studio 2012. Now here is the story, I woke up one morning and discovered I was departing from being a beginner programmer to a programmer who is at least worthy to be called a programmer. So I felt I needed to share my programming experience and the only known way I could do that, was to start blogging, hmmm... Just like you, I didn't like blogger, I needed  to be my own boss. So, I started my own blog project, but wait....  Why was I doing that when there are open source blog projects being developed and maintained by developers who are more "programmatically" experienced than I?. BlogEngine was the one I chose and the installation was a breeze. All I did was go to the site, downloaded the first zip file which is tagged "web", extracted it to my visual studio project directory, opened vi...

LOAN MANAGEMENT SYSTEM (My Project Idea)

There are many companies that specializes on giving loan to people; they make their profits by collecting interest on any money they lend out, and before a loan can be given to any customer, the customer must provide a collateral and some details such as:  contact details and a reference/guarantor. When the loan is finally given to the customer, they charge interest based on the the amount given to the customer for a given period of time which could be daily, weekly, monthly or yearly.  For example, a company could be collecting interest based on a particular amount for a given period of time like: $200,000 loan would have an interest tag of $2,000  per month until the money is returned, and $100,000 would have an interest of $1,000 per month until the money is returned.  In  addition, the customers need to know when the time for them to pay their interest comes e.g.  at the end of the month or the timing model with which the calculation is being made. Usua...