Sunday, December 29, 2013

Use GCC C++ Compiler "Hello World!" on Raspberry Pi

   
     Raspberry Pi have GCC C++ Compiler internal. You can develop program with C++ language by your self. This a simply program for use in same other language is "Hello World!". It print text message to the terminal console. You can do step below.

1. Check version of gcc c++ Compiler in your Raspberry Pi.


gcc -v                                                           




2. create new source c++ file.


nano hello.c                                                


3. Type a simple program.



#include <stdio.h>                                     
void main(int argc, char *argv[])               
{                                                                   
    printf("Hello world!\n");                          
    return;                                                     
}                                                                   

4. Save and compile.

gcc hello.c -o hello                                    

5. hello.c is your source file. The -o hello specifies that the executable output file should be called hellohello is just a file and not something that the Pi can run immediately. Linux requires that executable files have a particular set of file mode bits to specify that the file is executable. You use the chmod command to change the bits. The +x adds the executable bit to the file's permissions:

chmod +x hello                                           

6. Run the program

./hello                                                           

7. Output







No comments:

Post a Comment