mirror of
https://github.com/boostorg/more.git
synced 2025-01-16 02:40:10 +08:00
3c82e58140
[SVN r36493]
1.1 KiB
1.1 KiB
Link Your Program to a Boost Library
To demonstrate linking with a Boost binary library, we'll use the following simple program that extracts the subject lines from emails. It uses the Boost.Regex library, which has a separately-compiled binary component. :
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
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;
}
}
There are two main challenges associated with linking:
- Tool configuration, e.g. choosing command-line options or IDE build settings.
- Identifying the library binary, among all the build variants, whose compile configuration is compatible with the rest of your project.