The Standard C++ library depends on P.I.P.S.. The user must have the P.I.P.S. components installed before using the library.
C++ IOStream library documentation can be found at http://www.slac.stanford.edu/comp/unix/gnu-info/iostream_toc.html .
Similarly, Standard Template Library (STL) documentation can be found at http://www.informatik.uni-freiburg.de/~danlee/fun/STL-doc/STL.html .
Add needed libraries used by the MMP file structure:
If developers want to use any of Standard C++ library, they must link to the corresponding library in the MMP file using the LIBRARY keyword.
If the application has main() as the entry point, the library libcrt0.lib must be specified as the first library otherwise, it results in linker errors. The user must link to the Symbian platform euser.dll . This is required since the static library uses some of the services of the Symbian platform, such as, creating cleanup stack, and having a top level TRAP. All these details are hidden from the developer. The developer will write the application as if it were for the UNIX environment.
STATICLIBRARY libcrt0.lib LIBRARY libc.lib LIBRARY euser.lib // Needed in order to use Symbian services
The libcrt0.lib library is required for writing to E32Main within our application (EXE). This static library has an implementation of E32Main within which it calls the library initialization method followed by calling main written by the developer. This static library also retrieves command-line arguments and passes the same to main.
If the application has E32Main() as an entry point, there is no need to link to libcrt0.lib like in the example below.
LIBRARY libc.lib LIBRARY euser.lib
Add required include paths
SYSTEMINCLUDE \epoc32\include\stdapis SYSTEMINCLUDE \epoc32\include\stdapis\sys SYSTEMINCLUDE \epoc32\include\stdapis\stlport
Linking of libstdcpp
Following snippet shows how to perform the linking to libstdcpp on an emulator:
#ifdef EPOC32 LIBRARY libstdcpp.lib #else FIRSTLIB ../udeb/libstdcpp.lib STATICLIBRARY eexe.lib #endif
Add the below option and macro in the MMP file
//This is required even if the wchar type is not used. OPTION CW -wchar_t on MACRO _WCHAR_T_DECLARED
EPOCSTACKSIZE 0x10000
in the MMP file.
A simple example using main() as an entry point is described below. The example writes a text to a console.
Modify the MMP file as mentioned before.
Do usual C++ style coding.
// Include Files #include <iostream> #include <cstring> // This is a GCCE toolchain workaround needed when compiling with GCCE // and using main() entry point #ifdef __GCCE__ // This is a GCCE toolchain workaround needed when compiling with GCCE // and using main() entry point #ifdef __GCCE__ #include <staticlibinit_gcce.h> #endif using namespace std; class myclass { public: void show(){cout<<"Hello World\n"; } } ; int main() { myclass obj; obj.show(); cout<<"Press a character to exit!"; int c = getchar(); return 0; }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.