C-Language
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.
ON WINDOWS
Dev C++ is an open source C/C++ compiler that is one of the most user friendly and effective development environment and compiler. It can be downloaded from source forge or from bloodshed.
• 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.
ON LINUX
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,
gcc -v
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.
On CentOS/Redhat
yum install gcc gcc-c++ autoconf automake
On Debian
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-devel
Based on Wine-Staging (Bleeding Edge) (eg: 1.9.1) - sudo apt install wine-staging
Lastly run:
export WINEARCH=win32 andwinecfg in 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:
cd Desktop/
• 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
That's all.
Hope it worked.
Comments
Post a Comment