In this section, you will create a simple C program on Ubuntu OS using a pre-installed text editor. You have to repeat the steps mentioned in the above section to install the build-essential package / Development Tools again, and then you are good to go.Ĭreating a Simple C Program in Ubuntu Using Text Editor Note: If the Output looks like the below Output, there was some discrepancy during the installation process. If you see Output like the above-displayed Output on your screen, you have successfully installed the GCC compiler`. Note: -version flag under the GCC command is compatible with almost all the terminal development software in Linux. First, update the packages list using the below command as the root user: So, if you are using a Red Hat Linux / Fedora / CentOS-based Linux operating system, then you have to install the Development Tools package to get the GCC compiler in your system.ġ. In Red Hat Linux Fedora or CentOS operating systems, there is no build-essentials package present, but we can install a similar package in these operating systems that are required for software development. This version of Ubuntu comes with a pre-installed version of the GCC compiler, so you can first check the installed compiler version using the command mentioned in the below section. Note: We are using Ubuntu 20.04 LTS version in this tutorial. Now we can know how to compile the C program in Linux. This process will install the GCC Compiler on your Linux Operating System so that you can use this compiler to learn how to compile C Programs in Linux.Ĭongratulations! Now, you have successfully completed the installation of the build-essential package and the GCC Compiler. It will take up to 3-5 minutes to completely install the build-essential meta-package in your system. Press the Y key and then the Enter key once you get the same output above on your screen to continue the installation process. If required, enter your system password to proceed. To begin, update the packages list using the below command: You can use the shortcut key Ctrl + Alt + T, or manually open up the terminal by searching it in the menu option ( ⋮⋮⋮ icon).ġ. Let's see the steps involved in installing the build-essential package:įirst, you have to open up the terminal. Let's start the tutorial by installing the essential package, the build-essential package, in our Linux operating system. This tool will come in handy if you wish to package your program for a Debian-based system. dpkg-dev: This package can be used to unzip, compile, and upload Debian source packages.This tool reads a file called a " makefile", which tells the compiler how to do its job. make: This is a handy tool for controlling the compilation of programs.The development libraries and header files needed to know how to compile the C program in Linux are included in this package. libc6-dev: This is the GNU library files package.g++ : The GNU C++ compiler for compilation of programs written in C++ Language.gcc: The GNU Compiler Collection ( GCC Compiler) for compilation of programs written in C Language.All these five packages are listed below: We've got you covered with our step-by-step guide on compiling a C program in Linux! Why do We Need to Install the Build-Essential Package?īuild-essential meta-package in Ubuntu comes with five separate packages, including the GCC Compiler, that are required during a software compilation process, which will help compile a C program in Linux. We understand that installing a compiler for C in Linux might seem daunting, but don't worry. GCC Compiler (GNU Compiler Collection) is a collection of compilers and libraries for the programs written in C, C++, Ada, GO, D, Fortran, and Objective-C programming languages and is distributed under the GNU General Public License. If you're interested in learning more about the build-essential meta-package, You can refer here. In Ubuntu repositories, GCC Compiler is a part of the build-essential package, and this package is exactly what we will be installing in our Linux Operating System. The term compiler refers to a piece of software that converts our source code from a high-level programming language to a low-level programming language (machine-level code) to build an executable program file and in Linux Operating Systems and compile C program in Linux, we'll need to install the GCC Compiler. This executable can be run directly to run the C code. Mac C compilers compile C code into an executable. Various compilers are available in Mac to compile C code. C is a compiled language, meaning code must be compiled first to run it. A compiler is a program that converts high-level language like C, C++, Java, etc., to machine code understandable by a computer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |