Platform Environment: Windows 7 32-bit +VS2010+STL source code 5.2.1
STL in SourceForge download, if not can download, can download in csdn.
Download good source code, first extracted to the hard disk, I extracted to D:\STL.
Select "Visual Studio command Prompt (VS2010)" in VS2010 tools
In the cmd window, the directory switches to the root directory of the source just extracted,
Enter Configure-help to view compilation options
Display platform XP, here for the time being.
Input Configure MSVC9 configuration environment
The contents of the red box above do not need to be tube.
After you switch the directory to Build/lib, enter the NMAKE clean install compile and the following error occurs:
is the header file _cstdlib.h in the 158 line of the problem, with a 32-bit machine, _int64 may not support, comment out this line.
Find _cstdlib.h in directory Stlport-5.2.1\stlport\stl, comment out 158 lines
[CPP]View Plaincopy
- Inline _stlp_long_long abs (_stlp_long_long __x) {return __x < 0?-__x: __x;}
Then run NMAKE clean install to compile the installation, which takes several minutes.
It can then be used in the VS2010. Open VS2010, create a new project, I am new to the empty console project.
Right-click on the project-select Properties,
We are going to include the newly compiled library into this project, select the VC + + directory, add the Stlport-5.2.1\stlport directory in the Include directory, add the Stlport-5.2.1\lib directory in the library directory, and then OK.
Then copy the six files in the Stlport-5.2.1\bin directory to the root of the newly created project, and note that the "project root" is not the root directory of the entire solution. Then you can use it, and debugging can go into the source code to see the execution process.
STL can also be used with the following macro definitions:
[CPP]View Plaincopy
- #define _STLP_USE_STATIC_LIB//use STLport Static library
- #define _STLP_USE_DYNAMIC_LIB//using STLport Dynamic Library
- #define _STLP_DEBUG//STLport enable the check function in DEBUG mode
- #define _STLP_USE_BOOST_SUPPORT//STLport for use with the BOOST library
With the code of the newly built project, it is very simple to note that include uses double quotation marks, do not use angle brackets.
[CPP]View Plaincopy
- #include <iostream>
- #include "vector"
- Using namespace std;
- int main ()
- {
- vector<int> v;
- V.push_back (1);
- V.push_back (2);
- return 0;
- }
Win7 under vs2010 compile debugging STL source code