Hello World Example: Using P.I.P.S.

This example application shows a simple EXE and DLL written using P.I.P.S. (P.I.P.S. Is POSIX on Symbian Platform). It also shows the dynamic lookup of symbols by name mechanism used in Unix-like operating systems, instead of the native Symbian Platform lookup by ordinal mechanism. P.I.P.S., from Symbian OS v9.3, provides APIs from libdl library to implement this lookup by name mechanism.

The example defines a simple DLL using the P.I.P.S. STDDLL target type, with an exported function. It also creates a simple EXE, using the STDEXE target type, which calls the DLL's exported function using the lookup by name mechanism. These P.I.P.S. specific target types are required to enable the specific options for compilers and linkers to generate P.I.P.S. executables and to make symbol information available in the executable image.

Download

Click on the following link to download the example: HelloWorldExample.zip

Click: browse to view the example code.

Description

The following sections provide more information about the example.

Creating a simple DLL using P.I.P.S. STDDLL target type

The example creates a DLL file that declares and defines an exported function. The target type of this DLL file is STDDLL . It contains a header and a source file:

  • helloworlddllexample.h : this declares a function with external linkage. Note that for a STDDLL library, functions and data with external linkage are exported by default, without any requirement for IMPORT_C and EXPORT_C declarations in header or source files.

  • helloworlddllexample.cpp : this defines the function declared in the header file, which displays a hello world message to the console.

Creating a simple EXE using P.I.P.S. STDEXE target type

The example creates an EXE file which calls the exported function of the loaded DLL. The target type of this EXE file is STDEXE . It calls the following libdl functions to use the lookup by name mechanism:

  • dlopen() : This function is used to load the DLL file which contains an exported function.

  • dlsysm() : This function gets the address of a symbol defined within the DLL loaded by the dlopen() call.

  • dlclose() : This function informs the system that the DLL loaded by a previous dlopen() call is no longer needed by the application.

  • dlerror() : This function is used to get the last error that occurred from any of the libdl APIs.

The EXE links to libdl.lib to use these functions.

Build

The HelloWorldExample builds two files, a DLL file helloworlddllexample.dll , and an EXE file helloworldexeexample.exe , in the standard locations.

To run the example, start helloworldexeexample.exe from the file system or from your IDE. After launching the executable, depending on the emulator you are using, you may need to navigate away from the application launcher or shell screen to view the console.