Contents |
It is recommended to build Boost yourself, as this may avoid some problems and you are able to get the newest version. It is also very easy to do, as auto detection of VS works just fine.
download boost and unzip in %PROGRAMFILES%\boost or something like that download bjam.exe copy bjam.exe to boost dir start a command prompt, and run: bjam --toolset=msvc --build-type=complete stage
Note that --build-type=complete builds every possible library combination (unicode/non-unicode, static/dll, etc.) and this takes a long time (several hours on a slow machine) and takes up about 4.6 GB! If you know exactly what libraries you need, you can build just them, but otherwise I would recommend building with low priority, to avoid interfering with other work being done on the computer:
start /low bjam --toolset=msvc --build-type=complete stage
The resulting libs are place in the stage/ directory. The libraries should be moved to a lib/ directory created in the boost directory.
Like with all libraries, you have to:
Note that you don't have to specify which libraries to link with, as this is done by header magic!
If you have built boost, errors like
LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc90-mt-1_35.lib'
indicate that you either don't have the entered the right path to the libs in VS or you have built only the DLL versions of the boost libraries. The static versions are prepended with 'lib'. Note that:
boost_filesystem-vc90-mt-1_35.lib is a DLL import library, and libboost_filesystem-vc90-mt-1_35.lib is a static library
If you want to build universal binaries, you'll have to build it manually. Also, MacPorts seems to be very unstable right now, so I'll deprecate using it.
download and install XCode download boost
cd boost_VERSION/tools/jam/src sh build.sh
Example universal binary build:
bjam --toolset=darwin --build-type=complete --with-thread architecture=combined
Install
sudo bjam --prefix=/opt/local/ install
sudo port install boost +complete +docs
download boost download bjam executable for ntx86 unpack boost in c:\boost unpack bjam in c:\boost start cmd (building doesn't work in bash) start /low bjam --toolset=gcc --build-type=complete
Or build a single library:
start /low bjam --toolset=gcc --build-type=complete --with-thread
test-regex.cpp:
#include <boost/regex.hpp>
#include <iostream>
void check(const char *s) {
static const boost::regex re("h(i|ello)", boost::regex::icase);
if(regex_match(s, re))
std::cout << s << " matches.\n";
else std::cout << s << " doesn't match.\n";
}
main() {
check("HELLO");
check("hi there");
}
// output:
// HELLO matches.
// hi there doesn't match.
compile with:
g++ -Ic:\boost test-regex.cpp C:\boost\bin.v2\libs\regex\build\gcc-mingw-3.4.5\release\link-static\libboost_regex-mgw34-1_34.a
Here we use the direct specification of a link library. To be able to specify
the full path, we ignore the -l option and specify it directly.
To quote from the gcc manual:
Note that the sequence in which the linked objects are specified is
significant - it won't work if you exchange the source and the library
file; to quote from the gcc manual again:
... sigh.
emerge -av boost
g++ -lboost_regex test-regex.cpp
... so much easier :).