0 commentaires Text Size : [+] | [-]




gcc is the GNU Compiler Collection supporting various programming languages.

g++ is the traditional nickname of GNU C++, a freely redistributable C++ compiler. It is part of gcc.


The Linux kernel is written in the C programming language, with a small amount of assembly language in some places.

C is the most powerful programming language in popular use.

To build the kernel, the gcc C compiler must be used.

If you wish to download the compiler and build it yourself, you can find it at

http://gcc.gnu.org.

C++ is mostly an extension of C.

C++ has the main advantage of being an Object Oriented language.

To use C and C++ you will need to do to install the build-essential package.

sudo apt-get install build-essential

This will install all the required packages for C and C++ compilers

Testing C and C++ Programs.

Compiling your first C program.

You need to open test.c file

sudo gedit test.c

add the following lines save and exi
t the file


#include

int main()

{

printf("My First C\n");
return 0;

}

Compile the code using the following command

gcc -c test.c

That would produce an object file.

Then create an executable using the following command

gcc -o test test.c

Run this executable using the
following command

./test

Output should show as follows

My Ferst C

Compiling your first C++ program.

If you want to run c++ program follow this procedure

g++ is the compiler that you must use.

you should use a .cpp file extension rather than a .c one

You need to create a file

sudo gedit first.cpp

add the following lines save and exit the file




Run your C++ Program

g++ first.cpp -o test

./test

Output should show as follows

Hello World!


0 commentaires

Post a Comment

If you enjoyed this post, please consider leaving a comment or
Subscribe to ChamsBlog via RSS

Subscribe to chamsblog by Email