Difference between revisions of "HelloWorld"
JustinC474 (Talk | contribs) (→C++) |
Aqisecoxefi (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | ---- | ||
+ | <div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> | ||
+ | ---- | ||
+ | =[http://uvetysudema.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]= | ||
+ | ---- | ||
+ | =[http://uvetysudema.co.cc CLICK HERE]= | ||
+ | ---- | ||
+ | </div> | ||
This page will provide sample code for writing, compiling, and running HelloWorld in Python and C++ on your Overo COM. To do this it will be assumed you have Console access to your Overo. | This page will provide sample code for writing, compiling, and running HelloWorld in Python and C++ on your Overo COM. To do this it will be assumed you have Console access to your Overo. | ||
Line 6: | Line 14: | ||
This command opens a text editor nano, which allows you to edit the text in files. In this specific case, it is opening the file HelloWorld.py. If this file has existed before, it would have opened the existing file. However, since it did not, nano opens a new text file with if saved, will be saved as HelloWorld.py. | This command opens a text editor nano, which allows you to edit the text in files. In this specific case, it is opening the file HelloWorld.py. If this file has existed before, it would have opened the existing file. However, since it did not, nano opens a new text file with if saved, will be saved as HelloWorld.py. | ||
Write the following code in the file: | Write the following code in the file: | ||
− | print | + | print "Hello, Gumstix!" |
− | To write the file (save it) press: | + | To write the file (save it) press: <br> |
− | Ctrl + O | + | Ctrl + O <br> |
− | Then to quit back to the command line, press: | + | Then to quit back to the command line, press: <br> |
− | Ctrl + X | + | Ctrl + X <br> |
And finally, issue this command to run the program: | And finally, issue this command to run the program: | ||
python HelloWorld.py | python HelloWorld.py | ||
Line 28: | Line 36: | ||
nano HelloWorld.cpp | nano HelloWorld.cpp | ||
Once in the file, copy the following code to make HelloWorld in C++ | Once in the file, copy the following code to make HelloWorld in C++ | ||
− | #include | + | #include <iostream> |
using namespace std; | using namespace std; | ||
int main () { | int main () { | ||
− | cout | + | cout << "Gumstix runs on C++" << endl; |
return 0; | return 0; | ||
} | } | ||
− | Then write the file and exit back to the command line with: | + | Then write the file and exit back to the command line with: <br> |
Ctrl + O | Ctrl + O | ||
Ctrl + X | Ctrl + X | ||
Line 43: | Line 51: | ||
Then, run the program using the command: | Then, run the program using the command: | ||
./HelloWorld | ./HelloWorld | ||
− | This tells the computer to execute a file named HelloWorld located in the current directory (./). The outputs should be: | + | This tells the computer to execute a file named HelloWorld located in the current directory (./). The outputs should be: <br> |
Gumstix runs on C++ | Gumstix runs on C++ | ||
Congratulations! You have successfully written your first C++ program on your Overo COM! | Congratulations! You have successfully written your first C++ program on your Overo COM! | ||
Line 64: | Line 72: | ||
nano HelloWorld.c | nano HelloWorld.c | ||
Once in the file, copy the following code to make HelloWorld in C | Once in the file, copy the following code to make HelloWorld in C | ||
− | #include | + | #include <stdio.h> |
int main () { | int main () { | ||
− | printf( | + | printf("Gumstix runs on C\n"); |
return 0; | return 0; | ||
} | } | ||
− | Then write the file and exit back to the command line with: | + | Then write the file and exit back to the command line with: <br> |
Ctrl + O | Ctrl + O | ||
Ctrl + X | Ctrl + X | ||
Line 78: | Line 86: | ||
Then, run the program using the command: | Then, run the program using the command: | ||
./HelloWorld | ./HelloWorld | ||
− | This tells the computer to execute a file named HelloWorld located in the current directory (./). The outputs should be: | + | This tells the computer to execute a file named HelloWorld located in the current directory (./). The outputs should be: <br> |
Gumstix runs on C | Gumstix runs on C | ||
Congratulations! You have successfully written your first C program on your Overo COM! | Congratulations! You have successfully written your first C program on your Overo COM! |
Revision as of 14:43, 23 November 2010
This page will provide sample code for writing, compiling, and running HelloWorld in Python and C++ on your Overo COM. To do this it will be assumed you have Console access to your Overo.
Python
To start writing HelloWorld in Python, issue the following command
nano HelloWorld.py
This command opens a text editor nano, which allows you to edit the text in files. In this specific case, it is opening the file HelloWorld.py. If this file has existed before, it would have opened the existing file. However, since it did not, nano opens a new text file with if saved, will be saved as HelloWorld.py. Write the following code in the file:
print "Hello, Gumstix!"
To write the file (save it) press: <br> Ctrl + O <br> Then to quit back to the command line, press: <br> Ctrl + X <br> And finally, issue this command to run the program:
python HelloWorld.py
The program should output:
Hello Gumstix!
Congratulations! You have programmed your first Python program on your Overo. You may re-open HelloWorld.py using the nano command to change the outgoing text to whatever you would like.
C++
C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.
opkg update opkg install task-native-sdk
NOTE: Installing task-native-sdk can take 45 minutes to two hours. To do this you will need an active internet connection on your Overo COM
Once you have an environment that is capable of compiling and executing a C++ file, you need to write the file. First, lets write a C++ file. To open a text editor, issue the command:
nano HelloWorld.cpp
Once in the file, copy the following code to make HelloWorld in C++
#include <iostream> using namespace std; int main () { cout << "Gumstix runs on C++" << endl; return 0; }
Then write the file and exit back to the command line with: <br> Ctrl + O Ctrl + X
Next, to compile the program, issue the command:
g++ -o HelloWorld HelloWorld.cpp
This creates an executable object (HelloWorld) by using the g++ compiler on the C++ file HelloWorld.cpp. Then, run the program using the command:
./HelloWorld
This tells the computer to execute a file named HelloWorld located in the current directory (./). The outputs should be: <br>
Gumstix runs on C++
Congratulations! You have successfully written your first C++ program on your Overo COM!
C
Since C is very similar to C++, the following instructions will be very similar to the C++ instructions. If you have already followed the instructions The differences are:
- HelloWorld.cpp becomes HelloWorld.c
- The code is different
- g++ becomes gcc
The rest is the same. Below is the exact same instructions, just modified for writing, compiling and executing a C file.
C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.
opkg update opkg install task-native-sdk
NOTE: Installing task-native-sdk can take 45 minutes to two hours. To do this you will need an active internet connection on your Overo COM
Once you have an environment that is capable of compiling and executing a C file, you need to write the file. First, lets write a C file. To open a text editor, issue the command:
nano HelloWorld.c
Once in the file, copy the following code to make HelloWorld in C
#include <stdio.h> int main () { printf("Gumstix runs on C\n"); return 0; }
Then write the file and exit back to the command line with: <br> Ctrl + O Ctrl + X
Next, to compile the program, issue the command:
gcc -o HelloWorld HelloWorld.c
This creates an executable object (HelloWorld) by using the gcc compiler on the C file HelloWorld.c. Then, run the program using the command:
./HelloWorld
This tells the computer to execute a file named HelloWorld located in the current directory (./). The outputs should be: <br>
Gumstix runs on C
Congratulations! You have successfully written your first C program on your Overo COM!