in , , ,

How To Compile and Run a C/C++ program in Kali Linux

How To Install C/C++ Compiler in Kali Linux

How To Compile with Gcc  and G++ on Kali Linux

How to compile on kali linux 2018.1 c and C++

C is a high-level and general-purpose programming language … And as we knew, C++ is a programming language that was built off the C language. So .. How To Compile C/C++ programming language on Kali Linux 2018.1?

One of the best Compiler used on Kali Linux 2018.1 or any other Kali version, to compile C programming language is GCC, and for C++ language the gcc become g++. On this tutorial, we will show you how to use both of them.

How To Compile C program in Kali Linux

Penetration Testing with Kali Linux free training courseFor first lest’s start with the compilation of C programming language in Kali Linux 2018.1. The use of gcc is very simple. Let’s write a simple C program using any text editor you want.

Open the text editor and type your code, we will use for example gedit and the code will be a simple program :

# include<stdio.h>

int main()

print{“\nNow, Can You Write Your C Progtram in Kali Linux ??\n”}
return 0;


Save the file as “ProgramName.c”, in our example the name is SimpleProgram.c 

Now we will use gcc to compile the program, open the terminal and go to the folder where your “ProgramName.c” are located and type this command :

gcc -o Oject_Name ProgramName.c

The Object_Name is the output program, and ProgramName.c is our C program. That will create an executable that run on Kali Linux, and will display the message on terminal.

The following video tutorial will show you How to compile and Run C program in Kali Linux :

How To Compile C++ program on Kali Linux

Now we come to the C++ programming language, as we have seen for the C programming language and the use of gcc compiler on Kali Linux. We will use g++ for C++ program.

The process is the same, all we need is to change gcc with g++ and all we will be fine. If you don’t have g++ already installed on Kali Linux a simple command will do it for you:

apt-get install g++

Make sure to update and upgrade Kali Linux before starting the installation of g++.

The following video will show you How To compile and Run C++ program in Kali Linux:

The Question Now is : How To create an executable program that work for Windows?

How To Create Windows Executable Program in Kali Linux

To create Windows executable, you need to install mingw cross-compiler on Kali Linux:

sudo apt-get install mingw-w64

Then you can create 32-bit Windows executable with:

i686-w64-mingw32-gcc -o Object_Name32.exe ProgramName.c

And 64-bit Windows executable with:

x86_64-w64-mingw32-gcc -o Object_Name64.exe ProgramName.c

So, that was all we need to start Compiling C and C++  programs in Kali Linux, if you want to start C++ coding download this free ebook.

If you have encountered a problem or you have any questions or remarks please feel free to set a comment.

Feel free to share it with your friends … with love and prosperity K4LINUXTEAM.


What do you think?

108 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Leave a Reply

Your email address will not be published. Required fields are marked *

How to install and use wifiphisher on kali linux 2018.1 tutorials

Kali Linux Tutorials – Wifiphisher – How To Hack Wi-Fi ?