Building Enhance Libraries For Visual Studio CodeProject

From Love's Story
Jump to: navigation, search

The Boost initiative is the following hottest factor after STL for the C++ group. Whereas the documentation is kind of good, it may be overwhelming to get a fast start. This easy article explains a technique of constructing Boost libraries. I wrote it as a result of many questions within the newsgroups are about linker errors, which occur if you happen to try to hyperlink in opposition to a number of the Increase libraries. The original article was written with Enhance model 1.33, however the up to date version works only with the brand new Bjam syntax which was introduced with version 1.34. The build scripts work up to version 1.57.



Boost



< backlinks high Authority ="display:block;text-align:center;clear:both">Whereas most of the Enhance libraries are template-based mostly (i.e. header only), some of them - e.g. date-time, regex, filesystem, alerts - come with cpp supply information and thus require a library to be generated. Boost makes use of a construct system called Bjam, which might be configured for quite a lot of platforms. I work only on Windows with Visible Studio, so I am going to describe here a configuration for these mixture for Visible Studio 2003, 2008, 2010 and 2013.



Building Enhance



After downloading the Boost libraries and unpacking them in a folder - referenced in this article with , e.g. on my Laptop it's C:\work sdk\increase, the libraries should be constructed:



1. Construct Bjam2. Construct the Increase librariesConstructing Bjam



Bjam will be in-built two methods:



- Use the 'bootstrap.bat' batch file situated in . Run this batch file and Bjam will likely be routinely constructed and added to the foundation. As of boost 1.71 bjam.exe shouldn't be copied anymore. Use b2.exe as a substitute.- Construct Bjam 'manually': browse to \tools\construct\jam_src and run construct.bat from a command prompt. It will start to build Bjam, which ends up in \instruments\construct\jam_src\bin.ntx86\bjam.exe. Copy this file to the root of Increase, . The folder has been changed since then for the current version (enhance 1.71) \tools\construct\src\engineBuilding Increase Libraries



The Bjam system should be advised that you really want to build debug/release libraries, build with threading in thoughts, construct static or dynamic library and link towards varied options of the STL or platforms. I solely use Visual Studio with Plauger's STL and select for the next configuarion



1. Build a debug construct with multithreading and dynamic linking.2. Build a release construct with multithreading and dynamic linking.With the release of Visual Studio 2005 / 2008, Microsoft helps facet by aspect installations of the crt. With manifests, one can bind a module to a particular version of the crt. The Increase libraries are dependent on the crt as effectively, and you can instruct the construct process to use the most recent version by a '_BIND_TO_Present_VCLIBS_Model' outline.



Notice: the command lines use bjam.exe right here but b2.exe would work as effectively.



This results in the next options for Visual Studio 2003:



1. bjam toolset=msvc-7.1 variant=debug threading=multi link=shared2. bjam toolset=msvc-7.1 variant=release threading=multi hyperlink=sharedFor Visible Studio 2008:



1. bjam toolset=msvc-9.Zero variant=debug threading=multi hyperlink=shared outline=_BIND_TO_Present_VCLIBS_Version2. bjam toolset=msvc-9.0 variant=release threading=multi hyperlink=shared outline=_BIND_TO_Present_VCLIBS_VersionFor Visual Studio 2010:



1. bjam toolset=msvc-10.0 variant=debug threading=multi hyperlink=shared define=_BIND_TO_Current_VCLIBS_Model2. bjam toolset=msvc-10.Zero variant=launch threading=multi link=shared define=_BIND_TO_Current_VCLIBS_VersionFor Visual Studio 2013:



1. bjam toolset=msvc-12.0 variant=debug threading=multi hyperlink=shared define=_BIND_TO_Current_VCLIBS_Model2. bjam toolset=msvc-12.Zero variant=release threading=multi link=shared outline=_BIND_TO_Present_VCLIBS_VersionI've already made eight batch information with the same command(s). Remember that these are zip files since codeproject did not enable *.bat information to be uploaded:



zbuilddebug_vc71.batzbuildrelease_vc71.batzbuilddebug_vc90.batzbuildrelease_vc90.batzbuilddebug_vc100.batzbuildrelease_vc100.batzbuilddebug_vc120.batzbuildrelease_vc120.batUnzip and duplicate the batch information to the foundation of Boost, . Now the libraries will be built:



1. Open the command immediate.2. Run vcvars32.bat out of your favorite Visible Studio version.3. Run contextual backlink , e.g. zbuilddebug_vc71.bat.Bjam will now strive to build the libraries.



Constructing All



For the worrying software engineer, I supply here batch recordsdata which will do it all collectively: they construct bjam if it doesn't exist and construct the debug and launch mode libraries in one go:



zbuildall_vc71.batzbuildall_vc90.batzbuildall_vc100.batzbuildall_vc120.batAfter the construct process has finished, the library executables are created in the \bin.v2 listing, e.g.:



boost_date_time-vc120-mt-gd-1_57.dll for the multithreaded debug construct of a date-time library.enhance_date_time-vc120-mt-1_57.dll for the multithreaded launch build of a date-time library.As a result of all of those files are constructed underneath their very own library names, one can copy them all - i.e. search on 'mt-gd-1_57 and mt-1_57 - to at least one location and modify Visual Studio to level to this library location. Alternatively one can use the \stage listing. Nonetheless this directory does not comprise the related PDBs, which is unhandy during debugging.



Using Boost Libraries



We now have constructed the shared libraries and subsequently we need to instruct Visual Studio to link towards them. Fortuitously, Boost has integrated an "autolink" feature. Thus, with the preprocessor one can hyperlink to the correct libraries. Outline the following preprocessor statements:



Enhance_ALL_DYN_LinkIncrease_LIB_DIAGNOSTICEven better, embrace a header file in your precompiled header before together with a boost header:



BoostDefines.hppRoom for Improvement



- For some cause, the "regular," i.e. non-dynamic, libraries get built.- Python library also needs to get built, however for some reason it will get excluded.- Visual Studio 2005 introduces the safe C and iterator ideas. Increase libraries do not like them and must be turned off.- Precompiled Authority backlinks .