Difference between revisions of "BoostWindowsQuickRef"
(→Include Boost headers and link with Boost libraries: Corrected for C::B library autocorrect) |
(Updated for Boost 1.36.0) |
||
Line 13: | Line 13: | ||
=== Boost Source Code === | === Boost Source Code === | ||
− | The Boost libraries are distributed as source code archived in .7z, .tar.bz2, .tar.gz, or .zip format; choose whichever archive format is easiest for you to unpack. The current stable release of Boost is '''1. | + | The Boost libraries are distributed as source code archived in .7z, .tar.bz2, .tar.gz, or .zip format; choose whichever archive format is easiest for you to unpack. The current stable release of Boost is '''1.36.0'''. [http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=619445 Click here to browse the Boost 1.36.0 downloadable files]. You can check [http://www.boost.org/users/download/ the Boost download page] to see if a newer stable version is available. |
You also need to download Boost Jam in order to build Boost. The current stable release of Boost Jam is '''3.1.16'''. [http://downloads.sourceforge.net/boost/boost-jam-3.1.16-1-ntx86.zip Click here to download Boost Jam for Windows] (boost-jam-3.1.16-1-ntx86.zip; 115 KB). | You also need to download Boost Jam in order to build Boost. The current stable release of Boost Jam is '''3.1.16'''. [http://downloads.sourceforge.net/boost/boost-jam-3.1.16-1-ntx86.zip Click here to download Boost Jam for Windows] (boost-jam-3.1.16-1-ntx86.zip; 115 KB). | ||
− | '''It is highly recommended that you unpack the sources to a path without spaces.''' You should choose a volume with at least XXX MB of free space. Typically, the Boost sources and Boost Jam are unpacked in separate locations, ending up with "<path>\ | + | '''It is highly recommended that you unpack the sources to a path without spaces.''' You should choose a volume with at least XXX MB of free space. Typically, the Boost sources and Boost Jam are unpacked in separate locations, ending up with "<path>\boost_1_36_0" and "<path>\boost-jam-3.1.16-1-ntx86". |
=== Boost Installer for MSVC 2003 (7.1) or later === | === Boost Installer for MSVC 2003 (7.1) or later === | ||
Line 30: | Line 30: | ||
set PATH=<path>\boost-jam-3.1.16-1-ntx86;%PATH% | set PATH=<path>\boost-jam-3.1.16-1-ntx86;%PATH% | ||
* Change to the Boost sources directory (where <path> is the path you unpacked the Boost sources to): | * Change to the Boost sources directory (where <path> is the path you unpacked the Boost sources to): | ||
− | cd <path>\ | + | cd <path>\boost_1_36_0 |
* Execute the build command. The recommended command to use for '''MinGW/GCC''' is (where <installpath> is where you want the Boost headers and libraries; typically C:\Program Files\CodeBlocks): | * Execute the build command. The recommended command to use for '''MinGW/GCC''' is (where <installpath> is where you want the Boost headers and libraries; typically C:\Program Files\CodeBlocks): | ||
bjam --toolset=gcc "--prefix=<installpath>" install | bjam --toolset=gcc "--prefix=<installpath>" install | ||
Line 47: | Line 47: | ||
* Click the "New" button next to the Current variable list, specify a name like "boost", and hit OK | * Click the "New" button next to the Current variable list, specify a name like "boost", and hit OK | ||
* In the "base" field of the Builtin fields section, browse for the base of your Boost installation -- the path you specified in the --prefix option of the build command | * In the "base" field of the Builtin fields section, browse for the base of your Boost installation -- the path you specified in the --prefix option of the build command | ||
− | * In the "include" field, browse for the "include\boost- | + | * In the "include" field, browse for the "include\boost-1_36" subfolder of your Boost installation -- it should be the path in the "base" field with "\include\boost-1_36" tacked on. |
* Hit the Close button to save your global variable | * Hit the Close button to save your global variable | ||
Line 61: | Line 61: | ||
Your project is now ready to use the Boost libraries. For each library you want to use, do the following: | Your project is now ready to use the Boost libraries. For each library you want to use, do the following: | ||
* #include <boost/*.hpp> in your source file | * #include <boost/*.hpp> in your source file | ||
− | * In your project's build options, highlight the root of your project, select the "Linker settings" tab, and add "boost_*-mgw34-mt- | + | * In your project's build options, highlight the root of your project, select the "Linker settings" tab, and add "boost_*-mgw34-mt-1_36" to your Link libraries |
− | For examle, use "#include <boost/filesystem.hpp>" and "boost_filesystem-mgw34-mt- | + | For examle, use "#include <boost/filesystem.hpp>" and "boost_filesystem-mgw34-mt-1_36" to use boost.filesystem. |
== Frequently Asked Questions == | == Frequently Asked Questions == | ||
No Frequently Asked Questions (or Frequently Given Answers) have been entered yet. | No Frequently Asked Questions (or Frequently Given Answers) have been entered yet. |
Revision as of 19:33, 20 October 2008
A beginner's quick reference for setting up Boost with Code::Blocks in Windows
Supported compilers: MinGW or MSVC
Important Requirements:
- Windows compiler - You need to have correctly installed the free MinGW/GCC compiler or one of Microsoft's compilers (the Express editions are free, but you must also install the Platform SDK). The latest stable release of Code::Blocks includes a MinGW-bundled version which includes all necessary packages; or, if you install it by hand, you need at least the gcc-core, gcc-g++, binutils, w32api, and mingw32-make packages. Also, ensure that the folder containing the compiler executables (typically C:\Program Files\CodeBlocks\bin) is in your Windows PATH environment variable.
- Recent version of Code::Blocks - You need to have successfully installed and run a recent version of Code::Blocks -- either the latest stable release or [/index.php/board,20.0.html a recent nightly build].
Download Boost
You can download the Boost source code and compile it yourself, or, only if you are using MSVC 2003 (7.1) or later, you can use a web-based installer to download pre-built libraries.
Boost Source Code
The Boost libraries are distributed as source code archived in .7z, .tar.bz2, .tar.gz, or .zip format; choose whichever archive format is easiest for you to unpack. The current stable release of Boost is 1.36.0. Click here to browse the Boost 1.36.0 downloadable files. You can check the Boost download page to see if a newer stable version is available.
You also need to download Boost Jam in order to build Boost. The current stable release of Boost Jam is 3.1.16. Click here to download Boost Jam for Windows (boost-jam-3.1.16-1-ntx86.zip; 115 KB).
It is highly recommended that you unpack the sources to a path without spaces. You should choose a volume with at least XXX MB of free space. Typically, the Boost sources and Boost Jam are unpacked in separate locations, ending up with "<path>\boost_1_36_0" and "<path>\boost-jam-3.1.16-1-ntx86".
Boost Installer for MSVC 2003 (7.1) or later
BoostPro Computing distributes a free web-based installer that will download and install prebuilt versions of the Boost libraries for MSVC. Click here to browse the BoostPro Free Downloads. The amount of space used by the installation varies depending on which libraries and variants you choose.
Build Boost
This step is unnecessary if you are using the BoostPro installer
- Open up a command prompt for building. If you are using MinGW/GCC, simply use the standard Windows command shell (open the Start menu, click "Run...", enter "cmd" and hit OK). If you are using MSVC, you should use the special command shell which sets up the correct environment variables for you. If you use a version of MSVC which required you to download the Platform SDK separately, ensure that whichever command environment you use includes the Platform SDK tools and paths as well as the standard compiler tools and paths.
- Ensure that Boost Jam is in the PATH environment variable (where <path> is the path you unpacked Boost Jam to):
set PATH=<path>\boost-jam-3.1.16-1-ntx86;%PATH%
- Change to the Boost sources directory (where <path> is the path you unpacked the Boost sources to):
cd <path>\boost_1_36_0
- Execute the build command. The recommended command to use for MinGW/GCC is (where <installpath> is where you want the Boost headers and libraries; typically C:\Program Files\CodeBlocks):
bjam --toolset=gcc "--prefix=<installpath>" install
- The recommended command to use for MSVC is (where <installpath> is where you want the Boost headers and libraries):
bjam --toolset=msvc "--prefix=<installpath>" install
- This step will generally take 5-20 minutes, depending on the capabilities of your PC.
- The above commands will build release, multithreaded, DLL versions of the Boost libraries. If you want other variants, add --build-type=complete to the command line. This will take a much longer amount of time to build.
Add Boost to an existing project in Code::Blocks
The Boost libraries are usable in nearly any Code::Blocks project. You can create a new project that will use Boost or open an existing project. With your project open, perform these steps.
Set up a Code::Blocks global variable for Boost
This step only needs to be performed once, after which the global variable you've created will be available for any project.
- Open the Settings menu and select "Global variables..."
- Click the "New" button next to the Current variable list, specify a name like "boost", and hit OK
- In the "base" field of the Builtin fields section, browse for the base of your Boost installation -- the path you specified in the --prefix option of the build command
- In the "include" field, browse for the "include\boost-1_36" subfolder of your Boost installation -- it should be the path in the "base" field with "\include\boost-1_36" tacked on.
- Hit the Close button to save your global variable
Add Boost search directories to your project
- Right-click your project's name in the Projects section of the Management window and select "Build options..."
- Highlight the root of your project in the tree on the left side of the Project build options window
- Select the "Search directories" tab
- With the "Compiler" subtab selected, click the Add button, enter "$(#boost.include)" (without the quotes), and hit OK
If you are using the bundled version of MinGW with Code::Blocks, and you used your C::B installation in the --prefix option as recommended, the following step is unnecessary
- With the "Linker" subtab selected, click the Add button, enter "$(#boost.lib)" (without the quotes), and hit OK
Include Boost headers and link with Boost libraries
Your project is now ready to use the Boost libraries. For each library you want to use, do the following:
- #include <boost/*.hpp> in your source file
- In your project's build options, highlight the root of your project, select the "Linker settings" tab, and add "boost_*-mgw34-mt-1_36" to your Link libraries
For examle, use "#include <boost/filesystem.hpp>" and "boost_filesystem-mgw34-mt-1_36" to use boost.filesystem.
Frequently Asked Questions
No Frequently Asked Questions (or Frequently Given Answers) have been entered yet.