diff --git a/getting_started.html b/getting_started.html index 3cab7ff..01f0d0c 100644 --- a/getting_started.html +++ b/getting_started.html @@ -4,109 +4,142 @@
-This guide will help you get started using the Boost libraries. -Have fun!
-Welcome to the Boost libraries! By the time you've completed this +tutorial, you'll be at least somewhat comfortable with the contents +of a Boost distribution and how to go about using it.
+This document is designed to be an extremely gentle introduction, +so we included a fair amount of material that may already be very +familiar to you. To keep things simple, we also left out some +information intermediate and advanced users will probably want. At +the end of this document, we'll refer you on to resources that can +help you pursue these topics further.
+We use one typographic convention that might not be immediately +obvious: italic text in examples is meant as a descriptive +placeholder for something else, usually information that you'll +provide. For example:
++$ echo "My name is your name" ++
Here you're expected to imagine replacing the text “your name” with +your actual name.
+We identify Unix and its variants such as Linux, FreeBSD, and MacOS +collectively as *nix. If you're not targeting Microsoft Windows, +the instructions for *nix users will probably work for you. +Cygwin users working from the Cygwin bash prompt should also +follow the *nix instructions. To use your Cygwin compiler from +the Windows command prompt, follow the instructions for Windows +users.
+Although Boost supports a wide variety of Windows compilers +(including older Microsoft compilers), most instructions for +Windows users cover only the Visual Studio .NET 2003 and Visual +Studio 2005. We hope that gives you enough information to adapt +them for your own compiler or IDE.
+Onward
+++Good luck, and have fun!
+—the Boost Developers
+
There are basically three ways to get Boost on your system:
-Windows Installer: Boost Consulting provides an installer +for Windows platforms that installs a complete Boost +distribution, plus optional precompiled library binaries for +Visual Studio, and (optionally) a prebuilt version of the +bjam build tool.
+Download: users of other platforms—and Windows +users who prefer to build everything from scratch—can download +a complete Boost distribution from SourceForge.
----
-- - - - Windows users: - boost_1_34_0.exe is a program you can -run to unpack the distribution; if you prefer not to download -executable programs, get boost_1_34_0.zip and use an -external tool to decompress it. We don't recommend using -Windows' built-in decompression as it can be painfully slow -for large archives.
-- - *nix users: - Download boost_1_34_0.tar.bz2, then, in the +
+
- +
Windows: Download and run boost_1_34_0.exe +to unpack the distribution.1
+*nix: Download boost_1_34_0.tar.bz2. Then, in the directory where you want to put the Boost installation, execute
-+tar --bzip2 -xf /path/to/boost_1_34_0.tar.bz2
-
Boost packages from RedHat, Debian, or some other +distribution packager: these instructions may not work for you +if you use 3rd party packages, because other packagers sometimes +choose to break Boost up into several packages or to reorganize +the directory structure of the Boost distribution.2
+This is is a sketch of the directory structure you'll get when you unpack your Boost installation (windows users replace forward slashes with backslashes):
-boost_1_34_0/ .................The “boost root directory” - index.html ....................A copy of www.boost.org +boost_1_34_0/ .................The “boost root directory” + index.htm .........A copy of www.boost.org starts here boost/ .........................All Boost Header files - libs/ ............Tests, .cpps, docs, etc., by library2 + libs/ ............Tests, .cpps, docs, etc., by library3 index.html ........Library documentation starts here algorithm/ any/ @@ -117,7 +150,7 @@ slashes with backslashes): more/ ..........................Policy documents, etc. doc/ ...............A subset of all Boost library docs-
Header Organization
The organization of Boost library headers isn't entirely uniform, but most libraries follow a few patterns:
@@ -130,7 +163,7 @@ the Type Traits Library's is_void boost/type_traits/is_void.hpp.The first thing many people want to know is, “how do I build Boost?” The good news is that often, there's nothing to build.
-Header-Only Libraries
-Nearly all Boost libraries are header-only. That is, most -consist entirely of header files containing templates and inline -functions, and require no separately-compiled library binaries -or special treatment when linking.
-The only Boost libraries that are not header-only are:
+Nothing to Build
+Most Boost libraries are header-only: they consist entirely +of header files containing templates and inline functions, and +require no separately-compiled library binaries or special +treatment when linking.
+The only Boost libraries that can't be used without separate +compilation are:
The DateTime library has a separately-compiled -binary which is only needed if you're using a “legacy -compiler”(such as?). The Graph library has a -separately-compiled binary, but you won't need it unless you -intend to parse GraphViz files.
-The DateTime library has a separately-compiled component that +is only needed if you're using its to/from_string and/or +serialization features or if you're targeting Visual C++ 6.x or +Borland. The Graph library also has a separately-compiled part, +but you won't need it unless you intend to parse GraphViz +files.
-The following program reads a sequence of integers from standard -input, uses Boost.Lambda (a header-only library) to multiply each -one by three, and writes them to standard output:
+To keep things simple, let's start by using a header-only library. +The following program reads a sequence of integers from standard +input, uses Boost.Lambda to multiply each number by three, and +writes them to standard output:
#include <boost/lambda/lambda.hpp> #include <iostream> @@ -224,45 +263,45 @@ int main() in(std::cin), in(), std::cout << (_1 * 3) << " " ); }-
Start by copying the text of this program into a file called -example.cpp.
+Copy the text of this program into a file called example.cpp.
Simply issue the following command ($ represents the -prompt issued by the shell, so don't type that):
+In the directory where you saved example.cpp, issue the +following command:
-$ c++ -I /path/to/boost_1_34_0 example.cpp -o example +c++ -I /path/to/boost_1_34_0 example.cpp -o example
To test the result, type:
-$ echo 1 2 3 | ./example +echo 1 2 3 | ./example+
From your computer's Start menu, select if you are a Visual +
From your computer's Start menu, if you are a Visual Studio 2005 user, select
All Programs > Microsoft Visual Studio 2005 > Visual Studio Tools > Visual Studio 2005 Command Prompt-
or if you're a Visual Studio .NET 2003 user, select
+or, if you're a Visual Studio .NET 2003 user, select
All Programs > Microsoft Visual Studio .NET 2003 > Visual Studio .NET Tools > Visual Studio .NET 2003 Command Prompt-
to bring up a special command prompt window set up for the Visual +
to bring up a special command prompt window set up for the Visual Studio compiler. In that window, type the following command and -hit the return key (C:\PROMPT> represents the prompt issued by -the shell, so don't type that):
+hit the return key:-C:PROMPT> cl /EHsc /I C:\path\to\boost_1_34_0 example.cpp +cl /EHsc /Ipath\to\boost_1_34_0 path\to\example.cpp
To test the result, type:
-C:PROMPT> echo 1 2 3 | example +echo 1 2 3 | example+
Consult your vendor's documentation; if you have trouble adapting -these instructions to your build environment, request assistance on -the Boost Users' mailing list.
+Don't be alarmed if you see compiler warnings from Boost headers. +We try to eliminate them, but doing so isn't always practical.4
+Errors are another matter. If you're seeing compilation errors at +this point in the tutorial, check to be sure you've copied the +example program correctly and that you've correctly identified the +Boost root directory.
If you want to use any of the separately-compiled Boost libraries, -you'll need to get ahold of library binaries.
+you'll need library binaries.The Windows installer supplied by Boost Consulting will download and install pre-compiled binaries into the lib\ subdirectory of the boost root, typically C:\Program Files\boost\boost_1_34_0\lib\.
+Issue the following commands in the shell (again, $ represents -the shell's prompt):
+Issue the following commands in the shell (don't type $; it +represents the shell's prompt):
$ cd /path/to/boost_1_34_0 $ ./configure --help @@ -330,71 +373,29 @@ your installation prefix. You will also find a copy of the Boost headers in the include/ subdirectory of the installation prefix, so you can henceforth use that directory as an #include path in place of the Boost root directory. +
If you're not using Visual C++ 7.1 or 8.0, or you're a *nix user who wants want to build with a toolset other than your system's default, or if you want a nonstandard variant build of Boost (e.g. optimized, but with debug symbols), you'll need to use Boost.Build to create your own binaries.
-Boost.Build is a text-based system for developing, testing, and +installing software. To use it, you'll need an executable called +bjam.
Like an IDE, Boost.Build is a system for developing, testing, and -installing software. Instead of using a GUI, though, Boost.Build -is text-based, like make. Boost.Build is written in the -interpreted Boost.Jam language.
-To use Boost.Build, you'll need an executable called bjam, the -Boost.Jam interpreter.
- -Using command-line tools in Windows
-In Windows, a command-line tool is invoked by typing its name, -optionally followed by arguments, into a Command Prompt window -and pressing the Return (or Enter) key.
-To open Command Prompt, click the Start menu button, click -Run, type “cmd”, and then click OK.
-All commands are executed within the context of a current -directory in the filesystem. To set the current directory, -type:
--cd path\to\some\directory --
followed by Return. For example,
--cd C:\Program Files\boost\boost_1_34_0 --
One way to name a directory you know about is to write
--%HOMEDRIVE%%HOMEPATH%\directory-name --
which indicates a sibling folder of your “My Documents” folder.
-Long commands can be continued across several lines by typing -backslashes at the ends of all but the last line. Many of the -examples on this page use that technique to save horizontal -space.
-bjam is the command-line tool that drives the Boost Build +system. To build Boost binaries, you'll invoke bjam from the +Boost root.
Boost provides pre-compiled bjam executables for a variety of platforms. -Alternatively, you can build bjam yourself using the -instructions given in the Boost.Jam documentation.
-bjam is a command-line tool. To build Boost binaries, you'll -invoke bjam with the current directory set to the Boost root, -and with options described in the following sections.
+Alternatively, you can build bjam yourself using these +instructions.First, find the toolset corresponding to your compiler in the following table.
darwin | +Apple Computer | +Apple's version of the GCC +toolchain with support for +Darwin and MacOS X features +such as frameworks. | +|
gcc | The Gnu Project | -+ | Includes support for Cygwin +and MinGW compilers. |
hp_cxx | Hewlett Packard | @@ -466,7 +475,9 @@ operating system.||
sun | Sun | -+ | Only very recent versions are +known to work well with +Boost. |
vacpp | IBM | @@ -486,7 +497,7 @@ toolset from the table.using a special debug build of Python. | |
d | -building a debug version of your code.6 | +building a debug version of your code.8 | |
p | using the STLPort standard library rather than the default one supplied with your compiler. | ||
n | -using STLPort's deprecated “native iostreams” feature.7 | +using STLPort's deprecated “native iostreams” feature.9 |
To test our subject extraction, we'll filter the following text +file. Copy it out of your browser and save it as jayne.txt:
++To: George Shmidlap +From: Rita Marlowe +Subject: Will Success Spoil Rock Hunter? +--- +See subject. ++
In a command prompt window, type:
++path\to\compiled\example < path\to\jayne.txt ++
The program should respond with the email subject, “Will Success +Spoil Rock Hunter?”
+If you linked to a shared library, you may need to prepare some +platform-specific settings so that the system will be able to find +and load it when your program is run. Most platforms have an +environment variable to which you can add the directory containing +the library. On many platforms (Linux, FreeBSD) that variable is +LD_LIBRARY_PATH, but on MacOS it's DYLD_LIBRARY_PATH, and +on Cygwin it's simply PATH. In most shells other than csh +and tcsh, you can adjust the variable as follows (again, don't +type the $—that represents the shell prompt):
++$ VARIABLE_NAME=path/to/lib/directory:${VARIABLE_NAME} +$ export VARIABLE_NAME ++
On csh and tcsh, it's
++$ setenv VARIABLE_NAME path/to/lib/directory:${VARIABLE_NAME} ++
Once the necessary variable (if any) is set, you can run your +program as follows:
++$ path/to/compiled/example < path/to/jayne.txt ++
The program should respond with the email subject, “Will Success +Spoil Rock Hunter?”
+This concludes your introduction to Boost and using it with your +programs. Remember that this page is only supposed to get you +started and not describe every detail you might want to know about. +There are lots of resources you can pursue from this point onward. +If you can't find what you need, or there's anything we can do to +make this document clearer, please post it to the Boost Users' +mailing list.
+Note
+We're also very interested in what sort of material might +be appropriate for a “Book 2” in a Getting Started series.
+In Windows, a command-line tool is invoked by typing its name, +optionally followed by arguments, into a Command Prompt window +and pressing the Return (or Enter) key.
+To open Command Prompt, click the Start menu button, click +Run, type “cmd”, and then click OK.
+All commands are executed within the context of a current +directory in the filesystem. To set the current directory, +type:
++cd path\to\some\directory ++
followed by Return. For example,
++cd C:\Program Files\boost\boost_1_34_0 ++
One way to name a directory you know about is to write
++%HOMEDRIVE%%HOMEPATH%\directory-name ++
which indicates a sibling folder of your “My Documents” folder.
+Long commands can be continued across several lines by typing +backslashes at the ends of all but the last line. Many of the +examples on this page use that technique to save horizontal +space.
[1] | If you prefer not to download executable programs, download +boost_1_34_0.zip and use an external tool to decompress +it. We don't recommend using Windows' built-in decompression as +it can be painfully slow for large archives. |
[1] | If developers of Boost packages would like to work + |
[2] | If developers of Boost packages would like to work with us to make sure these instructions can be used with their packages, we'd be glad to help. Please make your interest known to the Boost developers' list. |
[2] | If you used the Windows installer from Boost + |
[3] | If you used the Windows installer from Boost Consulting and deselected “Source and Documentation” (it's selected by default), you won't see the libs/ subdirectory. That won't affect your ability to use precompiled binaries, but you won't be able to rebuild libraries from scratch. |
[4] | Remember that warnings are specific to each compiler +implementation. The developer of a given Boost library might +not have access to your compiler. Also, some warnings are +extremely difficult to eliminate in generic code, to the point +where it's not worth the trouble. Finally, some compilers don't +have any source code mechanism for suppressing warnings. |
[3] | There's no problem using Boost with precompiled headers; + |
[5] | There's no problem using Boost with precompiled headers; these instructions merely avoid precompiled headers because it would require Visual Studio-specific changes to the source code used in the examples. |
[4] | That option is a dash followed by a lowercase “L” + |
[6] | That option is a dash followed by a lowercase “L” character, which looks very much like a numeral 1 in some fonts. |
[5] | This convention distinguishes the static version of + |
[7] | This convention distinguishes the static version of a Boost library from the import library for an identically-configured Boost DLL, which would otherwise have the same name. |
[6] | These libraries were compiled without optimization + |
[8] | These libraries were compiled without optimization or inlining, with full debug symbols enabled, and without NDEBUG #defined. All though it's true that sometimes these choices don't affect binary compatibility with other @@ -824,18 +938,17 @@ compiled code, you can't count on that with Boost libraries. |
[7] | This feature of STLPort is deprecated because it's + |
[9] | This feature of STLPort is deprecated because it's impossible to make it work transparently to the user; we don't recommend it. |