1) Open the BeIDE application. You can do this by clicking on the Be icon on the Deskbar and going to the apps menu item, you'll find an entry for the BeIDE there.
// Opens the integrated development environment for BeOS x86 and PPC platforms.
2) From the menu, select File -> New Project
3) From the New Project window, select BeSTL. The BeSTL is the stationary for using the C++ Standard Template Library, and is best for a command line application such as this. You can find links to information about the STL at NPC.
4) The Save As Dialog appears. Save the file as "helloworld.proj". A new Project window (helloworld.proj) appears. A standard feature in most modern GUI's is you can click on "Untitled.proj" and highlight just the "Untitled" portion and rename that by just typing over it.
// Creates a new folder with a new project file named "helloworld.proj"5) Click on the BeIDE main window (should still read "Untitled 1", and it is not the "helloworld.proj" window). Type in the following code verbatim:
//*************************************************************** // You don't have to include this in your project // // Doubleslash comments out everything remaining on the line /* Comments out everything between it and the */ // Whitespace characters do not count //*************************************************************** #include <iostream> // includes the header file containing declarations for the for // input / output streams - to the terminal int main() /* Declares a main function (your program), which does not take any arguments for input, and returns an integer value for output to the BeOS*/ { // Begins the "main" code block cout << "Helloworld. My first C++ program." << endl; // Tells the OS to output to the terminal screen everything inside the quotes // And then flush the buffer by inserting the endline character. // Notice that every statement must end with a ";" character. return 0; // Returns the integer 0 back to the shell to indicate that the program // exited successfully. } // ends the "main" code block.
6) Select menu item File, click Save As. Name the file "helloworld.cpp". Check the "Add to Project" box. Click the Save button. The window should now be titled "helloworld.cpp".
// Save your code as "helloworld.cpp". The .cpp stands for c++ source.
7) Select the Window menu item and click on Settings... On the left side of the Dialog, find the "x86 ELF Project" item (and obviously, PPC Project on the PPC) and click on it. Under filename, change "BeSTL" to read "helloworld" and click the Save button, and then exit the Settings dialog by clicking the Cancel button.
// Name your program "helloworld" instead of BeApp.
8) Click on the "helloworld.proj" Project window. Select the Project menu item and click Make.
// This, among other things, will compile the code for you and place the resulting program // in your project folder.
9) Open the Terminal application located on the Deskbar menu under the Apps folder. Type "pwd". Ensure you are in the /boot/home directory. Type "cd helloworld" and enter. You can do "ls" to see all of the files in your projects directory (one of these had better be called helloworld and others should be called helloworld.cpp and helloworld.proj).
// Change directories into the project folder you made earlier.
10) Type in "helloworld" and press enter. You should see the Terminal display the following:
Helloworld. My first C++ program. // You enter the command to run your program, and it runs. After the program returns 0 to the // OS's shell program (which is running your program), // the shell knows your program exited successfully and the Terminal prompt appears.
11) Congratulations. You have just programmed your first program in C++ on the BeOS! After the initial excitement wears off, you can type "exit" to exit out of the Terminal, and close all BeIDE windows (or choose Quit from the File menu).
// Exit everything and get ready for the next one!
Next is a little user interaction using the istream cin - Go here to continue.