The Hello World example

We will first check that the SDK is correctly working:
- Open a DOS box,
- just type ‘NMAKE’ (without the quotes!), if you get a Microsoft Error message U1064, don’t worry, this was just to check your path is correctly configured. If you have an error message saying that NMAKE is not a recognised command, you should run the VCVARS32.BAT script that is located in C:\Program Files\Microsoft Visual Studio\VC98\Bin.

Or modify your path so that it includes the path to Microsoft command line compilation tools).

From the DOS box, move to the HelloWorld example in

C:\Symbian\6.1\Series60\Epoc32Ex\Basics\HelloWorld

You should have three files in this directory (if not, check that you are in the correct example, they are several “Hello World” example and we will only consider the simplest one by now):
- bld.inf
- helloworld.mmp
- helloworld.c

Bld.inf (Bld stands for Build) is the master project file. It generally contains the list of all makefiles (one for each component) that are part of the project. In our example, it only contain a reference to the helloworld.mmp makefile:

Bld.inf (Bld stands for Build) is the master project file. It generally contains the list of all makefiles (one for each component) that are part of the project. In our example, it only contain a reference to the helloworld.mmp makefile:


// BLD.INF

// Component description file

//

// Copyright (c) 2000 Symbian Ltd. All rights reserved.

PRJ_MMPFILES

HelloWorld.mmp

Helloworld.mmp is the project makefile. It contain the list of all source files and libraries that are part of the component:


// HelloWorld.mmp

//

// Copyright (c) 2000 Symbian Ltd. All rights reserved.

// using relative paths for sourcepath and user includes

TARGET HelloWorld.exe // The name of the target

TARGETTYPE exe // The type of the target

UID 0 // The Unique Identifier of the target

// ------------------------------------------------

// The source files

// ------------------------------------------------

// The relative path to the source files

SOURCEPATH .

// The list of source files

// (add as many statements as you need)

SOURCE HelloWorld.cpp

// ------------------------------------------------

// The includes files

// ------------------------------------------------

// Path to user include files (#include "file")

// (add as many statements as you need)

USERINCLUDE .

USERINCLUDE ..\CommonFramework

// Path to system include files (#include <file > )

// (add as many statements as you need)

SYSTEMINCLUDE \Epoc32\include

// ------------------------------------------------

// The libraries to link against

// ------------------------------------------------

// List of libraries you will use in your app

// (add as many statements as you need)

LIBRARY euser.lib

And last but not least, Helloworld.cpp is the C++ code which is quite self explanatory:


// 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);

}

The CommonFramework.h is a useful header file that set up a basic console environment and calls a doExampleL() primitive: this is an extremely useful file to begin playing Symbian C++ without the burden of NS60 specific code (you can also read A simple text console if you want to know more about this console).

Command line compilation

In the DOS box, type

bldmake bldfiles

You should not have any output on screen but a new file called ABLD.BAT has been created in the project directory. This is the entry point to the Perl script that is used to compile the application.

Now, we can compile our application. Type

abld build wins udeb

You should get a long and cryptic output describing the compilation.

However, you will notice that nothing as been created in the current project directory. Welcome to the wonderful world of Symbian. As a matter of fact, you cannot specify where the result of the compilation process will be stored. Let’s go to:

C:\Symbian\6.1\Series60\Epoc32\Release\wins\UDEB

he Helloworld.exe is there. Not very convenient. Type Helloworld and you should see the epoc emulator starting the “Hello world” application.

Working with Visual C++

If you are not a command line addict (which is probably your case since you are using Windows), you can also use Visual C++ to compile and execute your application.

Go back to C:\Symbian\6.1\Series60\Epoc32Ex\Basics\HelloWorld

The abld command generates a Visual C++ workspace:

abld makefile vc6

Once again, it is not located in the project directory. This time you will find it in-C:\Symbian\ 6.1\ Series60\ Epoc32\ BUILD\ SYMBIAN\ 6.1\ SERIES60\ EPOC32EX\ BASICS\ HELLOWORLD\ HELLOWORLD\ WINS

Open the workspace. Recompile and start your application using CTRL-F5. This will regenerate the Helloworld.exe file and start the emulator. You can also set some breakpoint and use the Microsoft debugger if you need to debug an application (maybe not with this example since there is not so many lines to debug!).

Target compilation

You may now want to compile this example to run it on your phone. Unfortunately, you cannot do that directly from Visual C++. Go back your DOS box, in the Go back to

C:\Symbian\6.1\Series60\Epoc32Ex\Basics\HelloWorld

Use the abld build command to compile but specify the THUMB or ARMI target:

abld build thumb urel

As usual, the result of the compilation is not in the project directory but in C:\Symbian\6.1\Series60\Epoc32\Release\thumb\UREL

file in this directory and send it over Bluetooth or Infrared to your phone:
- enable Bluetooth or Infrared on your mobile,
- move it so that it can connect to your PC,
- right click on the exe file,
- select Send To/Infrared (or Bluetooth)

Read Starting APP and EXE applications to check how to start the exe application.

Here it is. You should now be able to compile and run most of the basic examples found in the SDK directories. You can also take a look at the Overview of the Compilation system to know a little bit more on the ABLD command.

Advertisements

One Response

  1. reetings. I follow your site to wish you continued success.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: