![]() |
| How to install gcc in Ubuntu, Kali Linux on Virtual Machine? | IndianTechnoEra |
Aim - To install a C compiler in Virtual machine and execute sample program using.
Some of Linux OS contain C compiler gcc.
To check gcc in your system run gcc --version in the terminal of your OS.
If gcc will be in your system then you will show the gcc version like this
gcc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Install gcc in Linux/ Ubuntu by commands
Open Virtual-box software
Run your Operating System (Ubuntu/ Kali or any one)
Run the following command in terminal
sudo apt update
sudo apt install build-essential
sudo apt-get install manpages-dev
gcc --version
Or,
sudo apt install build-essential
sudo apt purge gcc
sudo apt-get autoremove
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt install gcc
gcc --version
After successful installed the gcc and get the version, follow the step to create a C program file and write the c-programming code and execute
Step 1: Open terminal
Step 2; Type sudo nano HelloWorld.c where HelloWorld is your name of c-program.
Step 3: Type the code of c-programming as given the following
#include <stdio.h>
int main(void){
printf("Hello World \n");
}
Step 4: Press Ctrl+O and Ctrl+X key combinations for saving the file
Step 5: Then exit from the editor mode respectively.
Step 6: For compiling, type the command as:
gcc HelloWorld.c –o HelloWorld
Step 7: For execution of the file, type as:
./HelloWorld
Step 8: Now result of the C program will be displayed.
Or instead of install by terminal you can download gcc.ova and you can use only as per need at the time to import this downloaded file. Just follow the step
1. Open VirtualBox.
2. Select File -> Import Appliance -> Select file named ‘ubuntu15 with gcc.ova’ ->
Open ->Next -> Import.
3. Select ‘ubuntu15’ virtual machine and select start button.
4. Enter into terminal mode and type as ‘sudo nano first.c’. and follow as crate execute command
