hello, world

| 4 Comments | No TrackBacks

Let's test our environment by writing a simple console based hello world program.

Brian W. Kernighan and Dennis M. Ritchie wrote this on the classic book The C Programming Language

The only way to learn a new programming language is by writing programs in it. The first programs in it. The first program to write is the same for all languages: Print the words
hello, world

This is the big hurdle; to leap over it you have to be able to create the program text somewhere, compile it successfully, load it, run it, and find out where your output went.

From this link:


A "hello world" program can be a useful sanity test to make sure that a language's compiler, development environment, and run-time environment are correctly installed. Configuring a complete programming tool chain from scratch to the point where even trivial programs can be compiled and run may involve substantial amounts of work. For this reason, a simple program is used first when testing a new tool chain.

While small test programs existed since the development of programmable computers, the tradition of using the phrase "Hello, world!" as the test message was influenced by an example program in the book The C rogramming Language, by Brian Kernighan and Dennis Ritchie. The example program from that book prints "hello, world" (i.e., no capital letters, no exclamation sign).

Well, I'm to lazzy, so lets just use the supplied hello world program located at:

\Symbian\6.1\Series60\Epoc32Ex\basics\helloworld

The "\Symbian\6.1\Series60" part depends on your Symbian SDK, but the "Epoc32Ex\basics\helloworld" part is the same.

Here is the code for the HelloWorld.cpp:


// HelloWorld.cpp
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
#include "CommonFramework.h"
// do the example
LOCAL_C void doExampleL()
{
_LIT(KHelloWorldText,"Hello world!\n");
console->Printf(KHelloWorldText);
}

You will also need an mmp (HelloWorld.mmp) file which contains:


// HelloWorld.mmp
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
//
// using relative paths for sourcepath and user includes
//
TARGET HelloWorld.exe
TARGETTYPE exe
UID 0
//
SOURCEPATH .
SOURCE HelloWorld.cpp
//
USERINCLUDE .
USERINCLUDE ..\CommonFramework
SYSTEMINCLUDE Epoc32include
//
LIBRARY euser.lib

And finally a bld.inf file


// BLD.INF
// Component description file
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
PRJ_MMPFILES
//only one project
HelloWorld.mmp

Go to the source directory (or to be precise, go to the directory containing the bld.inf file). Compile the program by typing this :

bldmake bldfiles

and then

abld build wins udeb

To run this program, go to

\Symbian\6.1\Series60\Epoc32\Release\wins\udeb

And type:


helloworld.exe

If it works, you environment is sane. I will explain the code and the purpose of the .mmp and .inf files on my next postings.

No TrackBacks

TrackBack URL: http://symbian.compactbyte.com/mt/mt-tb.cgi/3

4 Comments

thanks

please explain me about basic program of symbian cpp.since m the fresher i have no idea about this platform and m not a good programmer so tell me to which field to choose (R&d or testing)

i just want to know flow of the program "HelloWord"

nice post..

Leave a comment

About this Entry

This page contains a single entry by Yohanes Nugroho published on June 2, 2004 12:54 PM.

Free compiler for the Symbian Emulator on Windows was the previous entry in this blog.

Hello World explained is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.