Compiling newest Boost_1_53_0 with VS2008

来源:互联网 发布:淘宝热销商品 编辑:程序博客网 时间:2024/06/05 06:49

BOOST WITH VISUAL STUDIO 2008

By xiaoxiong

xiongxiang2006@126.com

 

Pre: Everybody know that the boost library is a greatest C++STL library, It provide many interface in all sorts of library, such as thread,string ,math, allocate, math and so on.

 

For the needed of thesis, I need to find out a way toachieve the thread pool and the memory pool…. Let’s go through the topic ofconfigure the boost with VS2008.

 

1.      Prepare the package of boost, which can downloadfrom the http://www.boost.org. The latestversion is boost_1_53_0;

2.      Unpackaged the file “boost_1_53_0.zip”(or othersame name) to your specific path, such as my own path is “D:\Program Files(x86)\boost_1_53_0”;


3.      Run the “Visual Studio 2008 Command Prompt”console window.

And redirect to the boost source file path.For example,Input

D:

cd D:\Program Files(x86)\boost_1_53_0

 

4.      Now, we are in boost file directory, and knowexecute command (run bootstrap.bat),

bootstrap.bat

 

And the execute

bjam.exe --toolset=msvc-9.0 --build-type=complete stage 

NOTE:

a.      the *.lib file would put in to the folder“stage”.

b.     the command default compile the full library ofboost, you can also specific the library you interest in, and use these command

c.       bootstrap.bat --toolset=msvc-9.0 --with-system -with-thread

 

5.      Know you can enjoy yourself with a cup of tea ordo something others, it always take bit long time to compile, it depends onyour personal computer performance.

6.      As you have complete the compile , You may seefollows informations,

...failed updating 3 targets...

...skipped 2 targets...

...updated 3146 targets...

It said that you have success build thelibrary, We can continue the steps

 

 

7.      Open the VS2008, and configure the “Project andSolutions”(use combination key “Alt+t+o “, and choose the “Project andSolutions->VC++ Ditectories”), add choose “WIN32” plateform

.

8.      Add “Include files”, insert new line, and pastthe boost source absolute path way, such as “D:\Program Files (x86)\boost_1_53_0”;

 

Add “Library files”, as bellow, add “D:\ProgramFiles (x86)\boost_1_53_0\stage\lib”;

 

9.      Test for the boost library.

Create a new console project and past thesecode.

// boostUsage.cpp -- after compling theboost library, it's the first time to use boost library.

#include<iostream>

#include<string>

#include"boost/regex.hpp"

using namespace std;

using namespace boost;

 

int main(int argc, char* argv[])

{

   int myend;

   int new_counter=0;

   int delete_counter=0;

   boost::regex reg("(new)|(delete)");

   boost::smatch m;

   std::string s="Calls to new must be followed by delete.\

                  Calling simply new results ina leak!";

   std::string ::const_iterator it=s.begin();

   std::string::const_iterator end=s.end();

    while(boost::regex_search(it,end,m,reg))

    {

       m[1].matched?++new_counter:++delete_counter;

       it=m[0].second;

    }

   if(new_counter!=delete_counter)

       std::cout<<"Leak detected!\n";

   else

       std::cout<<"Semms ok...\n";

 

   cin>>myend;

 

   return 0;

}

 

If you did as the follow steps, you willsee the resul “Semms ok…”.