diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-5B3F5296-D6D0-5D25-8362-141DF5927E52.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-5B3F5296-D6D0-5D25-8362-141DF5927E52.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,55 @@ + + + + + +Troubleshooting

This topic describes how to troubleshoot issues that you may face while writing or building Std C++ code on Symbian platform.

Errors while building Std C++ Code

Problem

You may get a build error when you create a static library as illustrated in the following code and link it with an STDEXE.

The .mmp file of the static library:

//operator_new_failure_example_lib.mmp +Target operator_new_failure_example_lib.lib +Targettype lib +Source op_new_in_lib.cpp +Systeminclude /epoc32/include/stdapis/stlportv5 +Systeminclude /epoc32/include/stdapis

The .cpp file of operator new reference in the static library example:

// op_new_in_lib.cpp contents +#include <new> +int doSomething() + { + try + { + int *ptr = new int(0); // This refers the StdC++ operator new + //do something moreā€¦ + } + catch (std::bad_alloc) + { + return 1; + } + delete ptr; + return 0; + }

The .mmp file of the STDEXE that links with the static library:

//operator_new_failure_example.mmp +Target operator_new_failure_example.exe +Targettype stdexe +Source op_new_in_stdexe.cpp +Systeminclude /epoc32/include/stdapis/stlportv5 +Systeminclude /epoc32/include/stdapis +Library libstdcppv5.lib libc.lib +Staticlibrary operator_new_failure_example_lib.lib +Capability all -tcb

The .cpp file of operator new reference in static library example:

// op_new_in_stdexe.cpp contents looks as follows: +int main() + { + // the doSomething function is defined in the static library operator_new_failure_example_lib.lib that this exe is linking against. + return doSomething(); + }

Solution

The build error is caused because this code violates rule 5 under the Guidelines for Writing Standard C++ Libraries section. As per the rule, a static library of target type LIB cannot be linked against an STDEXE or STDDLL, unless it has the MMP keyword, STDCPP in its .mmp file.

You can fix the build error by adding STDCPP in the operator_new_failure_example_lib.mmp file as shown in the following code:

//operator_new_failure_example_lib.mmp +Target operator_new_failure_example_lib.lib +Targettype lib +//The STDCPP keyword specifies Standard C++ +STDCPP +Source op_new_in_lib.cpp +Systeminclude /epoc32/include/stdapis/stlportv5 +Systeminclude /epoc32/include/stdapis
Copyright Acknowledgments for Standard C++ + (STLport) Standard C++ Library Overview Standard C++ Support on Symbian Platform Developing Applications or Libraries + Using Standard C++ Building a Standard C++ Application or + Library Known Issues
\ No newline at end of file