]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Copyright David Abrahams 2006. Distributed under the Boost |
2 | .. Software License, Version 1.0. (See accompanying | |
3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
4 | ||
5 | Link Your Program to a Boost Library | |
6 | ==================================== | |
7 | ||
8 | To demonstrate linking with a Boost binary library, we'll use the | |
9 | following simple program that extracts the subject lines from | |
10 | emails. It uses the Boost.Regex_ library, which has a | |
11 | separately-compiled binary component. :: | |
12 | ||
13 | #include <boost/regex.hpp> | |
14 | #include <iostream> | |
15 | #include <string> | |
16 | ||
17 | int main() | |
18 | { | |
19 | std::string line; | |
20 | boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); | |
21 | ||
22 | while (std::cin) | |
23 | { | |
24 | std::getline(std::cin, line); | |
25 | boost::smatch matches; | |
26 | if (boost::regex_match(line, matches, pat)) | |
27 | std::cout << matches[2] << std::endl; | |
28 | } | |
29 | } | |
30 | ||
31 | There are two main challenges associated with linking: | |
32 | ||
33 | 1. Tool configuration, e.g. choosing command-line options or IDE | |
34 | build settings. | |
35 | ||
36 | 2. Identifying the library binary, among all the build variants, | |
37 | whose compile configuration is compatible with the rest of your | |
38 | project. | |
39 |