The C programming language is one of the most popular and widely used programming languages. It is a general-purpose programming language and there are very few computer systems in existence that are not set up for its use (i.e. where a C compiler does not exist).
Here will see how to set up a C IDE.
• Download the setup file from any of the above links or from somewhere it is feasile.
• Install it and open the IDE. Click on ‘New project’ from the menu File to the top left.
•Type in your code. Next comes the task of saving the source code in c source format. Give it a name and from the drop down menu which appeares in the save window select ‘c source file’ and then click save.
•After saving, click on the compile button from the menu or press F9. If there are no syntax errors in your code, the program will be compiled amd will be set ready for execution.
•To execute it click on ‘Run’ or press ‘Ctrl+F10’. It is done for now.
Linux based distributions like ubuntu, kali etc usually come pre installed with GCC(GNU Compiler Collection). It is used for compiling C/C++ source codes. To check if your Linux has gcc installed, type in the Terminal,
If yes, it will gove you details about your version and so on. Else you can follow the method given to get it installed. Type the commands corresponding to your Linux distribution.
yum install gcc gcc-c++ autoconf automake
sudo apt-get install build-essential
Now you have the compiler installed. One aother method is to install ‘Wine’ which is a software in Linuxbwhich enables Windows applications to be run on it.
- If you are using a 64-bit Architecture, then enable 32-bit for better compatibility
sudo dpkg --add-architecture i386
- Add the repository:
sudo add-apt-repository ppa:wine/wine-builds
- Update your Repositories:
sudo apt update
- Then install the version of Wine you wish to use:Based on Wine Development (Testing Stage) (eg: 1.9) –
sudo apt install wine-develBased on Wine-Staging (Bleeding Edge) (eg: 1.9.1) –
sudo apt install wine-staging
winecfgin the terminal to make sure it configures Wine correctly (In that order). You will also need to install
winetricks(Another configuration package, really helpful for installing Windows components like .NET Framework and other needed libraries). So after this, please do:
sudo apt install winetricks
Alright. No let us see how to run a c program on Linux.
• First of all open any text editor and type in your source code and save it to a directory(let us take Desktop) with the extension .c
• Then, open Terminal(Ctrl+Shift+T or from the appilcation menu). Change the workind directory to the location where you have saved the program. Since here it is Desktop, type:
• Again type gcc [<program_name.c>] This will compile the source code and if there are any errors in the code, error messages will be displayed in the screen. Else a new executable file will be generated in the same directory where you are working now with an extension .out .
• If the program was compiled successfully then type ./<executable_program_name>.out
There are many android applications which helps in compiling C/C++ programs on Android devices. You can have detailed explanations here.
Hope it worked.