I used STL in the program, but when downloaded, there was a link error:
Errors while downloading PPCEC603gnu / Project1.out: clone__Q2t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i03Rep eos__t18string_char_traits1Zc replace__t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0UiUiPCcUi _t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0 $ nilRep __dl__Q2t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i03RepPv length__t18string_char_traits1ZcPCc assign__t18string_char_traits1ZcRcRCc
The program code is as follows:
#include
#include
#include
#include
#include
Using namespace std;
Int main (void)
{
Map
Mapint [12] = 1222;
Mapint [13] = 1333;
IF (1222 == Mapint [12]) CERR << "Right! / N";
IF (1333 == Mapint [13]) CERR << "Right! / N";
String str = "hello";
Printf ("% s / n", str.c_str ());
Vector
Arrint.push_back (2);
Arrint.push_back (3);
Vector
ITARRINT = arrint.begin (); itarrint! = arrint.end (); iTARRINT)
{
CERR << * ITARRINT << "/ t";
}
CERR << ENDL;
Return 0;
}
but,
VxWorks is a support for STL. in
VxWorks Programmer's Guide has clearly shown that STL:
Standard Template Library (STL) For both toolchains, the Standard Template library consists entirely of a set of header files. There is no special run-time component that must be included in a VxWorks system.
STL for GNU The GNU STL port for VxWorks is thread safe at the class level This means that the client has to provide explicit locking, if two tasks want to use the same container object (a semaphore can be used to do so;. See 2.3 . .3 Semaphores) However, two different objects of the same STL container class can be accessed concurrently.The C Standard Template Library can be used in client code compiled with exception handling turned off in our implementation this has the following semantics.:
For all checks that could reasonably be made by the caller, such as bounds checking, no action is taken where an exception would have been thrown. With optimization on, this is equivalent to removing the check. For memory exhaustion where bad_alloc would have been thrown ., now the following message is logged (if logging is included): "STL Memory allocation failed and exceptions disabled -calling terminate" and the task calls terminate This behavior applies only to the default allocators; you are free to define custom allocators with a DiffERENT Behavior.
It was also found on FAQ that it supported STL, but it would make the code look relatively large:
Q. When Compiling C Code (STL) The Object Size Explodes
A: People Are Confusing C with Stl. There is an Embedded C Standard That Will Significantly Reduce The Size of An Executable if You Follow The Restrictions.
Compile with "-fno-exceptions". If you are using templates that require exceptions handling, i suggest you do not. Alternatively, you can look that the offending vxWorks STL file (maybe stl_alloc.h) and there is an "if 0 "Condition That Should Be Changed to" IF 1 ". Also disable RTTI with" -fno-rtti "as the another poster noted. You might also consider Using" -fno-volatile ", etc.if you don't use templates, BUST CLASS AND POLYMORPHISM, You CAN Make Your OWN Collections That Are Significantly Smaller Than STL. (Even WHEN You DO Use Templates).
Other Alternatives Might Be to Look at Pj Plaugher's STL.
(From: Bill PringleMeir, spam_account@sympatico.ca)
Moreover, for SET, MAP, VECTOR, there is no error, only String error. After repeated finding information, it is determined that only String is not related to STRING, and is related to STL, and described below in Programmer's Guide:
7.2.2 Add Support Components
By Default, VxWorks Kernels Contain Only Minimal C Support. You CAN Add C FunctionAryness by Including Any OR All of the Following Components:
Basic Support Components
...
C Library Components
Several C Library Components Are Also Available.
GNU-Specific Library Support Components
For the GNU Compiler, There Are:
INCLUDE_CPLUS
IncludDes All Basic C Run-Time Support in VxWorks. This enables you to Download and Run Compiled and Munched C Modules.
INCLUDE_CPLUS_STL
Includes Support for the Standard Template Library.
INCLUDE_CPLUS_STRING
Includes The Basic Components of The String Type library.
At this time, I went to see configall.h before I found that INCLUDE_CPLUS_STRING macro did not define.
Conclusion: I have too little to compile the compilation process, the library, and GCC, check this problem, there is no shortage at all.