Compiling newest Boost_1_53_0 with VS2008

BOOST WITH VISUAL STUDIO 2008

By xiaoxiong

[email protected]

 

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”;

Compiling newest Boost_1_53_0 with VS2008_第1张图片

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

Compiling newest Boost_1_53_0 with VS2008_第2张图片

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

D:

cd D:\Program Files(x86)\boost_1_53_0

 Compiling newest Boost_1_53_0 with VS2008_第3张图片

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

bootstrap.bat

 Compiling newest Boost_1_53_0 with VS2008_第4张图片

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

 Compiling newest Boost_1_53_0 with VS2008_第5张图片

 

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

.Compiling newest Boost_1_53_0 with VS2008_第6张图片

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

 Compiling newest Boost_1_53_0 with VS2008_第7张图片

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

 Compiling newest Boost_1_53_0 with VS2008_第8张图片

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…”.

 

 

你可能感兴趣的:(C++,OS,vs2008,boost)