Install STLport and boost libraries in Win7 + vs Express for Desktop

Source: Internet
Author: User

First, install the STLport
STLport is to move SGI STL kuping to each platform. The SGI Library is characterized by its very high efficiency. Boost running on this library is more efficient than the VS self-brought STL library. So we prefer to install STLport.

    1. Download stlport:http://sourceforge.net/projects/stlport/The latest version is 5.2.1

    2. Put it under the C packing directory and unzip it. Go to "vs2012 x86 native Tools command Prompt". (Note: not with cmd)

    3. Go to the "C:\STLPort" directory and run the command "Configure Msvc9". The msvc9 should correspond to the vs2008. Now STLport does not support a higher vs version. So, just press MSVC9 to configure.
    4. "CD C:\STLport\lib", run "nmake-f msvc.mak clean Install".
      This time there will be an error, as follows:
      *c:\stlport\stlport\stl/_cstdlib.h (158): Error c2084:function ' __int64 abs (__int64) ' already has a body
      C:\Program Files\Microsoft Visual Studio 10.0\vc\include. /include/stdlib.h (471): see previous definition of ' abs '
      Nmake:fatal error U1077: ' "C:\ProgramFiles\Microsoft Visual Studio 10.0\vc\bin\cl. EXE "': Return code ' 0x2 ' *
    5. The workaround is to find the "C:\STLport\stlport\stl_cstdlib.h" file, in 158 rows, by the
inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x): __x; }

Change to:

#    if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600)inline _STLP_LONG_LONG  return0 ? -__x : __x; }#    endif
    1. No surprises, wait 20 minutes, it should be compiled.
    2. Delete intermediate files in the "Stlport\build\lib\obj" directory (approximately 300M), save disk artifacts
    3. Set VS, prioritize using STLport's header file and Lib library

      1. first need Open a Project
      2. select Menu "Project–>xx Properties ..."
      3. Select "Configuration:all Configurations" in the top dropdown menu, otherwise each time you create New project has to be set once, bored to death ~
      4. found "configuration properties–> VC + + Directories"
      5. modify three directories: "Include Directorie S ", add" C:\STLPort\stlport ";" Library Directories "join" C:\STLPort\lib ";" Excutable Directories "add" C:\STLPort\bin "
      6. find "configuration properties–> general–>character Set", set to "not set"
      7. Locate "Configuration properties–>preprocessor–> Preprocessor Definitions", add "_stlp_debug" and "__stl_debug", This allows you to dynamically link to the STLport Debug version of the library at debug time, allowing you to go deep into the debug.
      8. Locate the "configuration properties–>preprocessor–> Code generation–> Runtime Library", set to "Multi Thread". * To distinguish between debug version and release version, respectively, corresponding to the different compiled target.

Second, install the Boost library
Boost provides features that are not available in STL, such as multithreading, regular expressions, functional programming, and so on. It is said that boost will be included in STL as a standard.

  1. Download Boost Library: http://www.boost.org/Now the latest version is 1.58.0
  2. Put in the C packing directory decompression, get "C:\boost" (changed the directory name, removed the version number)
  3. Use "vs2012 x86 native Tools command Prompt" to go to the above directory and run the batch file: "Bootstrap.bat" in "C:\boost" Directory to generate B2.exe,bjam.exe, and Project-config.jam
  4. Open the Project-config.jam file with a text editor and modify it to add a line of "using Stlport:stlport:c:/stlport/stlport:c:/stlport/lib;" To compile using STLport as the underlying library. Note: The path is separated by a colon, not a semicolon or a space, and the two paths added above are the header file path and the Lib library path, respectively.
  5. Type the command "Bjam threading=multi link=shared,static runtime-link=shared stdlib=stlport–stagedir=./stage" to compile ... A long wait
  6. The compilation is complete. On my machine, failed updated 658 targets, skipped 808 targets, updated 813 targets ...
  7. Continue to set up project so that you can take advantage of the files and compiled results from the Boost library
    1. First you need to open a project
    2. Select Menu "Project–>xx Properties ..."
    3. Select "Configuration:all Configurations" from the top drop-down menu
    4. Locate "Configuration properties–> c/c++->general->additional Include Directories", set the Boost header file path, "C:\boost\ Boost
    5. Locate "Configuration properties–> c/c++->linker->additional Library Directories", set the Boost library file path, "C:\boost\stage \lib ". Older versions, which need to be copy&paste out of the compiled path, are now seemingly generated in the stage directory.

Third, try
Find a piece of code from the Internet as follows:

#include <iostream>#include <vector>#include <boost/timer.hpp>using namespace STD;using namespaceBoostintMain () {STD:: vector<int>vt//stlport's vector! Timer T;//Construct a Timer object    cout<<"Max TimeSpan:"<<t.elapsed_max ()/3600<<"H"<<endl;//Timer MAX Timer    cout<<"min TimeSpan:"<<t.elapsed_min () <<"S"<<endl;//Timer minimum Timing (resolution)    cout<<"Now time elapsed:"<<t.elapsed () <<"S"<<endl;//How long has it been since the timer object was built?System"Pause");return 0; }

The results of the operation are as follows:

max timespan:596.523hmin timespan:0.001time elapsed:0.011anyto continue . . .

Iv. Reference Links
Http://blog.sina.com.cn/s/blog_6f62c9510101svk7.html
http://blog.csdn.net/ajioy/article/details/7304530
Http://www.cnblogs.com/fullsail/archive/2011/10/07/2200948.html
Http://www.xuebuyuan.com/608176.html

Five, PostScript
Using a STLport library can be faster, but debugging STLport objects in VS is inconvenient. One of the typical examples is vector. With the VS vector, you can see the value of each element in the vector directly in the debug window. If you use STLport, you must write "vt._m_non_dbg_impl._m_start[2" in the window to see the value of the third element in vector Vt.
I removed the STLport header file and the library file reference in the above configure, by default with the VS own STL to compile the "four" in the program, also can compile through, and run through.

Finish.

Installing STLport and boost libraries in Win7 + vs Express for desktop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.