Should i learn boost




















Parappa Parappa 7, 2 2 gold badges 33 33 silver badges 38 38 bronze badges. True Boost seems to be regarded as some mythical beast among many professional game programmers.

Too bad more people don't use it. At the game company I worked at, it was indeed a licensing problem. While nothing in the boost license prevented us from developing games with it, we weren't insured against potential future litigation regarding its use. So we were effectively paid to repeatedly reinvent the wheel, poorly.

I asked a game programmer friend of mine if he used boost about a year ago, to which he replied: "boost? Community Bot 1 1 1 silver badge. Rob Rob Anteru Anteru A language is a tool. Use it if it helps you accomplish something. Matthew Matthew 49 1 1 bronze badge. Very good answer! Finally, when you apply to job posting, they will ask you questions that are often equivalent of what those library does, sorting would be a good example.

How could you answer those questions if you always have used libraries for everything! I would prefer my programmers to know and use libraries vigorously instead of reinventing the wheel typically a worse wheel. Since the Boost libraries are based on, and extend, the standard, you should know the standard well. You should understand and be able to use containers, iterators, and algorithms, and ideally you should have heard of concepts such as RAII , function objects, and predicates. The better you know the standard, the more you will benefit from the Boost libraries.

For example, the keyword auto is used to avoid specifying types explicitly. Constructors are called through uniform initialization: variables are initialized, if possible, with a pair of curly brackets instead of parentheses. Many examples use lambda functions to make code shorter and more compact.

It is also used for code examples, command line options, and program output. A monospace bold font is used for variable names, objects, and user input. Community Boost welcomes and thrives on participation from a variety of individuals and organizations. Downloads Current Release Version 1.

Release Notes Download Documentation. News Version 1. Copyright Beman Dawes, David Abrahams, I prefer the 7-Zip or the bzip2 archives, as they have the best compression ratios. We will use Boost libraries Version 1. There are several optional packages that are used to provide additional functionality by certain Boost libraries when present. These include:. The zlib and bzip2 development libraries, used by Boost. IOStream to read and write compressed archives in gzip and bzip2 formats.

The ICU i18n development libraries, which are heavily used by Boost. Locale and also by Boost. Regex to support Unicode regular expressions. The expat XML parser library, used by the Boost. Some of these libraries may be made available through your native package management systems, particularly on Linux. When installed from such packages, the Boost build system may find these libraries automatically and link them by default.

If you chose to build these libraries from source and installed them at non-standard locations instead, then you should use specific environment variables to point to the installation directory of these libraries or to the include and library directories.

The following table summarizes these optional libraries, their source websites, Ubuntu package names, and the environment variables needed by Boost to identify them when installed from source:. Ubuntu packages: zlib1g , zlib1g-dev , and zlib1c.

Ubuntu packages: libexpat1 and libexpat1-dev. We will be using the gzip and bzip2 libraries in Chapter 9 , Files, Directories, and IOStreams , to compress data, while we will not be using the ICU and Expat libraries for the code examples in this book.

If you choose not to install a binary distribution of Boost or if such a distribution is not available for your platform, then you must build the Boost libraries from source.

Download the source archives for the Boost libraries, zlib and bzip2. Generate the Boost build system for your toolset. Extract the bzip2 and zlib source archives and make a note of the directories they have been extracted to. The --build-dir option would identify the directory in which the intermediate products of the build are created. Once you have downloaded the Boost source archive, from a Windows Explorer session, create a directory called boost-src and extract the source archive inside this directory.

Assuming that you want to install Boost in the boost-dir directory and boost-build is the directory in which the intermediate products of the build are kept, perform the following steps from a command prompt:. On a bit system with bit Visual Studio installation, you will have to run this command instead:. Extract the bzip2 and zlib source archives, and make a note of the directories they have been extracted to. Build the libraries and install them.

If you want to build bit libraries, use the following command line:. This last step builds and installs the necessary headers and libraries in the following directories:. Let us take a look at the various options we have used in the preceding commands:. The --build-dir option will identify the directory in which the intermediate products of the build are created.

The and bit builds will take place in separate intermediate directories identified by the --build-dir option and will be copied to separate library directories identified by the --libdir option.

If you have installed Boost in a nonstandard location which is typically the case if you have not installed it from a native package , then you will need to make sure that your preprocessor can find the Boost header files you have included using the —I option in the compiler:. This step will create an object file called chkfile.

You can specify which library to link to using the -l option. In case of a nonstandard installation, you will need to ensure that the linker can find the path to the library you want to link against using the -L option:. The preceding command line will work for either a static or a shared library. However, if both types of library are found, it will use the shared version. You can override this with appropriate linker options:. In the preceding case, the filesystem library is linked statically while others are linked dynamically.

The -Wl switch is used to pass its arguments to the linker. In this case, it passes the -Bstatic and -Bdynamic switches. If it is a shared library that you link against, then at runtime the dynamic linker needs to locate the shared library and load it too.

The way to ensure this varies from one version of Unix to the other. One way to ensure this is to embed a search path in your executable using the rpath linker directive:. Other ways besides using the rpath mechanism also exist. Linux uses a utility called ldconfig to locate shared libraries and update search paths. For more details, look at the man pages for ldconfig 8.

On Solaris, the crle utility performs a similar action. Using the Visual Studio IDE, we will have to tweak certain project settings in order to link against the Boost libraries. From the menu, select Project Project Properties. Edit the value of Additional Include Directories by adding the path to your Boost, include directories.

Separate it from other entries in the field using a semicolon:. Next, ensure that your linker is able to find the shared or static libraries. Edit the Additional Library Directories field to add the path to the Boost libraries, separated by a semicolon from any other entries:. Now you can leverage Boost's auto-linking feature on Windows to automatically link to the correct libraries.

If you built your Boost libraries on Windows with the default layout versioned , this is all you will need to do for linking correctly. You will get a linker error without these definitions:. You should now be able to build your project from your IDE without any problems. In order to run your program, the dynamic linker must be able to locate the dynamic library. For running your programs from within the IDE, you can add the path of your Boost libraries to the PATH variable by navigating to Debugging Environment , as shown in the following screenshot:.

You should download and build these examples on your development machines. With CMake, you can easily generate a build system of your choice on an operating system of your choice, using a single set of CMake specifications.



0コメント

  • 1000 / 1000