VS2008 under direct installation using Boost library 1.46.1 Version number

Source: Internet
Author: User

The boost library is a portable, source-sourced C + + library that is backed up as a standard library and is one of the engines of the C + + standardization process. The Boost library was launched by the C + + Standards Committee Library team, some of which are expected to be the next generation of C + + standard library content. In the C + + community is very influential, is the absolute "quasi" standard library. Boost because of its emphasis on cross-platform, the emphasis on standard C + + is independent of the authoring platform. Most of the boost library features need to contain only the corresponding header files, a few (such as the normal table of the library, file system library, etc.) need to link the library. But there are a lot of things that are experimental in boost, and it's useful to be cautious in actual development. Boost is enhanced in some playback software and sound effects, such as bass boost, woofer boost.

1. Download the latest version of the Boost library, the current update is 1.46.1 (published in 2011-3-12), download link address: HTTP://SOURCEFORGE.NET/PROJECTS/BOOST/FILES/BOOST/1.46.1/

2. Unzip to the hard disk and its folder is constructed as

boost_1_46_1/..... boost root folder--------------.....
Index.htm .... www.boost.org. Home page of the homepage of the site of the ...
boost/......... .............. All Boost header files
lib/........ ................. Pre-compiled binary libraries
Libs/........ ......... Library of tests,. CPPS, Docs, etc.
Index.html ......... ............. Library documents start at the beginning
algorithm/
any/
array/
... more libraries ...
status/......... .......... Boost-wide test Suite
tools/...... Useful tools, e.g. Bjam, Quickbook, bcp
More/....... ....................... Some documents
doc/......... ............... Part of all library documents

3. Under the root folder, open theindex.html, on the top of the "Getting Started"There is an introduction to how to start using boost, most of the boost library just needs to include the header file, and a few need to compile the link." Here is the boost library that must be compiled:
* Boost.filesystem
* Boost.graphparallel
* Boost.iostreams
* Boost.mpi
* Boost.programoptions
* Boost.python
* Boost.regex
* Boost.serialization
* Boost.signals
* Boost.system
* Boost.thread
* Boost.wave
In addition, some libraries can be optionally compiled:
* Boost.datetime (only if you need to use it for to_string/from_string or serialization features, or if you ' re targeting Visual C + + 6.x or Borla nd.
* Boost.graph (only if you tend to parse GraphViz files)
* Boost.math (the TR1 and C99 Cmath functions)
* Boost.random (when you need to use Random_device)
* Boost.test (can be used in "header-only" or "separately compiled" mode)
4. Start with a demo sample that directly uses the header file without compiling boost:
① Open Visual Studio 2008, create a new visual C++project, based on the WIN32 console program, Project named example, OK, after that, in the popup dialog box "Application Settings" ticked "Console ApplicationandEmpty Project", point" complete ";
② Right-click Exampleproject in the Solution Explorer, select Properties → C + + →General→attach include folder, enter the folder where you just unzipped the BOOST, like "F:/mycode/boost/boost_1_46_1", for example, as seen in:

③ Right click on the "source file" → "add" → "new Item" → Left "code" → select "C + + file (. cpp)" On the right, the file name is called example, click "Add", enter the following code:

#include<boost/lambda/lambda.hpp>
#include<iostream>
#include<iterator>
#include<algorithm>

intMain()
{
usingnamespaceBoost::lambda;
typedefstd::istream_iterator<int> in;

Std::for_each (
In (Std::cin), in (), Std::cout << (_1 *3) <<" ");
}

④ Click on the menu bar "Generate" → " Generate solution ", normal words will be compiled through, press F5 to see the results, such as the results as seen:

The function of this example code is to read a series of integers from the standard input, then use the boost::lambda to multiply each number by 3, and then write the results into standard output.


5. If you need to use the library that must compile the link, then you have to build the build boost library. The official documentation describes the ability to use the installation version, or compile the source code, especially recommended in the Microsoft Visual Studio development environment to use the installation version, because the installation version can be downloaded directly, and with pre-compiled libraries, save yourself the trouble of compiling the source code. In this case, since I am using Visual Studio 2008, I would like to try the installation version. Installation version is Boostpro site production, the installation version is not with the official boost synchronization, will be later than some time will be published. Current Latest version Boostpro 1.46.1 Installer (197K. exe),: http://www.boostpro.com/download/

5.1 Implementation of the installation version, all the way "I Agree", attention will be connected to the network, must be released. After that will pop up select Download boost C + + library 1.46.1 image address, the default is good, continue "Next", pop-up Select the default compilation type, select "Visual C + + 9" on the left side, select the type on the right side, We generally use the execution of cubby more use multi-threading, can look at the above Exampleproject properties, for example, as seen in:

To do this, we just need to select the above four options, and then choose between dynamic links and static link requirements, for example, as seen in:

The next step is to select the component installation, no problem is the default, then select the path, and then start to download, for example, as seen in:

Because it is connected to the network download, so a longer period of time, after downloading will be installed on their own initiative, in the Set folder there is a Lib folder, which is compiled good library.
5.2 Now let's take a look at the libraries that need to be linked with talent:
① Open the above established Exampleproject, change its CPP file code to such as the following:

#include<boost/regex.hpp>
#include<iostream>
#include<string>

intMain()
{
Std::string Line;
Boost::regex Pat ("^subject: (Re: | Aw:) * (. *) ");

while(std::cin)
{
Std::getline (std::cin, line);
Boost::smatch matches;
if(Boost::regex_match (line, matches, Pat))
Std::cout << matches[2] << Std::endl;
}
}

At this point, if the solution is generated, you will be prompted fatal error LNK1104: Unable to open the file "Libboost_regex-vc90-mt-gd-1_46_1.lib"
② Right-Example solution, select "Properties" → "Configuration Properties" → " linker " → " Additional library folder " to join the installation version of the Lib Library folder path, for example to see:

③ in the menu bar "generate" drop-down Select "Build Solution", no warning no error passed. Save the following text as a text document, the file name is jayne.txt, and the contents are as follows:

To:george Shmidlap
From:rita Marlowe
Subject:will Success Spoil Rock Hunter?
---
See subject.

Then save to the Debug folder in the project folder. Then win+r enter cmd into the console, the CD goes to this debug folder, enter the example < jayne.txt command, for example to see:

After a carriage return, the contents of the subject theme in the text document are matched by a regular match, for example, as seen:

can also not enter the CMD console, directly in the example solution right-click "Properties" → " debug " → "Command parameters", input < jayne.txt , press "OK", directly ctrl+f5 execute the program, The results for example are as seen in:


6. Finally, the Visual Studio environment can download the installation version, save the hassle of the compilation process, but without the help document, this has to be downloaded from the official site, now there are Chinese boost documents, and some good Chinese sites, such as the following:
Boost document Chinese: http://code.google.com/p/boost-doc-zh/
Online Chinese version of the document: http://www.cppprog.com/boost_doc/

Attach my compiled library boost1.46.1_vs2008 multithreaded Static library version number: http://download.csdn.net/source/3147458

VS2008 under direct installation using Boost library 1.46.1 Version number

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.