How to Add the RegEx Library in C++
Most of the Boost library works just fine by adding headers to your application code. However, a few components, such as RegEx, require a library. Before you can use a library, you must build it. After you build the library, you must add it to your application.
There are two techniques for adding the required headers and libraries to an application. The first technique is to add it to the compiler settings. The second technique is to add the settings to a specific project.
You use the first technique when you work with Boost for a large number of projects and require access to all libraries. The second technique is best when you use Boost only for specific projects and require access only to specific libraries.
The following steps show you how to perform the project-specific setup for any library, not just the RegEx library:
1Use the Project wizard to create a new project.
Every application begins with a new project.
2Choose Project→Build Options.
Code::Blocks displays the Project Build Options dialog box.
3Select the Linker Settings tab.
You see a number of linker settings, including a Link Libraries list, which will be blank.
5Click the Browse button — the button sporting the ellipses.
You see the Choose Library to Link dialog box.
6Using the dialog box, navigate to thelibboost_regex-mgw47-mt-1_55.alibrary (the release version of the library), select the library, and then click OK.
The Boost library files are typically located in the Boostlib directory. When you click OK, you see a dialog box that asks whether you want to keep this as a relative path.
Relative paths specify a location using the current location as a starting point. The alternative is an absolute path, which specifies a location based on the root directory of your hard drive. In most cases, absolute paths are less likely to get broken.
You see the absolute path for the libboost_regex-mgw47-mt-1_55.a library added to the File field of the Add Library dialog box.
After you click OK, you see the absolute path for the library added to the Linker Settings.
9Click the Search Directories tab.
You see three sub-tabs: Compiler, Linker, and Resource Compiler.
11Type the location of the Boost header files in the Directory field.
As an alternative, you can click the Browse button to use a Browse for Folder dialog box to find them. The files are normally located in the Boostincludeboost-1_55 folder.
13Click Add in the Linker sub-tab.
You see yet another Add Directory dialog box.
14Type the location of the Boost library files in the Directory field and then click OK.
The Boost library files are typically located in the Boostlib directory. After you click OK, you see the directory added to the Linker tab.
The RegEx library is now ready for inclusion in your application.