Installation
The Boost libraries come as source code. While most of the libraries consist solely of header files that can be used directly, some of the libraries require compilation. In order to make installation as easy as possible, an automated installation process based on Boost.Build is available. Instead of validating and compiling individual libraries separately, Boost.Build installs the complete set automatically. Boost.Build can be used with many operating systems and compilers and is able to compile each individual library based on appropriate configuration files.
To automatically install the Boost libraries with Boost.Build , the command-line program bjam is used. The Boost libraries ship this program as source code and not as an executable. Therefore, two steps are required to build and install the Boost libraries. After you download the Boost libraries, change to the Boost directory and enter the following commands on the command line:
Enter bootstrap on Windows and ./bootstrap.sh on other platforms, such as Linux, to compile bjam . The script automatically searches for a C compiler to build bjam .
Then, enter bjam on Windows and ./bjam on other platforms to start installing the Boost libraries.
You use bootstrap only once to build bjam . However, you might need to use bjam more often because bjam supports command-line options to build the Boost libraries in different ways. If you start bjam without any command-line options, a default configuration will be used. Because the default configuration is not always appropriate, you should know the most important command-line options:
The command-line options stage and install specify whether the Boost libraries are installed in a subdirectory called stage or are made available system wide. The meaning of system wide depends on the operating system. On Windows, the target directory is C:\Boost ; on Linux it is /usr/local . The target directory can also be specified with the —prefix option. Starting bjam without command-line options always means stage .
If bjam is called without any command-line options, it will search for a suitable C++ compiler. A specific compiler can be selected using the —toolset option. To select Visual C++ 2013 on Windows, call bjam with —toolset=msvc-12.0 . To select the GCC compiler on Linux, use —toolset=gcc .
The command-line option —build-type determines which build types of the libraries are created. By default, this option is set to minimal , meaning that only release builds are created. This may become an issue for developers who want to create debug builds of their projects with Visual C++ or GCC. Because these compilers automatically try to link against the debug builds of the Boost libraries, an error message will be displayed. In this case the option —build-type should be set to complete to generate both debug and release builds of the Boost libraries. This can take quite some time, which is why complete is not the default.
Boost libraries that have to be compiled are made available on Windows with file names that contain version numbers and various tokens. They make it possible, for example, to tell whether a library has been built as a debug or release variant. libboost_atomic-vc120-mt-gd-1_56 is such a file name. This library was built with Visual C++ 2013. It belongs to the Boost libraries 1.56.0. It is a debug variant and can be used in multithreaded programs. With the command-line option —layout , bjam can be told to generate other file names. For example, if you set it to system , the same file would be called libboost_atomic . On Linux, system is the default setting. If you want file names on Linux to be the same as those generated on Windows by default, set —layout to versioned .
To create both debug and release builds of the Boost libraries with Visual C++ 2013 and install them in the directory D:\Boost , enter the following command:
bjam —toolset=msvc-12.0 —build-type=complete —prefix=D:\Boost install
To build them on Linux and install them in the default directory, the command would be:
bjam —toolset=gcc —build-type=complete install
There are many other command-line options that you can use to specify in detail how to compile the Boost libraries. Have a look at the following command:
bjam —toolset=msvc-12.0 debug release link=static runtime-link=shared install
The debug and release options cause both debug and release builds to be generated. link=static only creates static libraries. runtime-link=shared specifies that the C++ runtime library is dynamically linked, which is the default setting for projects in Visual C++ 2013.
Как установить boost c
Boost library is a set of a popular collection of peer-reviewed, free, open-source C++ libraries. It supports a number of tasks such as unit testing, image processing, multithreading, and mathematical aspects such as linear algebra and regular expressions. You can also store, numbers that are out of range of long long, or double. It was first made available on September 1st, 1999. There are 164 different libraries in it. In this article, we will learn, how to install the boost library in C++ on Windows.
Installing Boost Library in C++ on Windows:
Step 1: Go to Boost.org. Click on the Downloads option on the right side.
Step 2: Click on the boost_1_72_0.zip file, to download the required boost library. It has an approx. size of 200MB.
Step 3: Now, open the location where your zip file is downloaded. For example: This PC > Local Disk (C:) > Users > jh > Downloads > .
Step 4: Select the zip file. Right-Click on it, and select Extract All…
Step 5: The files get extracted at the same location, with the same folder name. Now, go to Program Files, and create a new folder name Boost.
Step 6: Now, copy the extracted folder boost_1_72_0 into the boost folder. Hence, the boost library is installed into our system.
Verify the Installation of the Boost Library in C++
The successful compilation of the code will prove that the boost library is installed in windows.
Как установить библиотеку boost?
Библиотека boost — это набор частично компилируемых исходных кодов. В некоторых случаях ничего не нужно собирать, достаточно скачать с официального сайта дистрибутив, разместить в удобном месте и в настройках проекта указать пути.
У меня в специальной папке, где я храню библиотеки многоразового использования, лежит подпапка boost_1_56_0 . Рядом с нею еще ряд других более старых версий этой библиотеки.
В переменные среды (в windows это там же, где и PATH) я заношу переменную BOOST_ROOT , которая указывает на последнюю сборку. Т.е. как появится новая, я создам папку boost_1_XX_Y и переназначу эту переменную.
В настройках любых проектов мне достаточно указать $(BOOST_ROOT)\include — для доступа к headers, и $(BOOST_ROOT)\stage\lib32 / $(BOOST_ROOT)\stage\lib64 для доступа к конкретным библиотекам, нужной мне разрядности.
Поскольку boost автоматически выдает имена собираемым библиотекам, с учетом компиляторов, которыми они собираются, даже если у Вас разные компиляторы, бинарники удобно сбрасывать в одну папку, как указано выше.
- С Intel Compiler у Вас получатся libboost_name-iw-type-version.lib .
- С Visual Studio у Вас получатся libboost_name-vcXX-type-version.lib , где XX — версия компилятора visual studio (не студии, а именно компилятора).
- С MinGW с gcc у Вас получится libboost_name-gcc-type-version.lib , если мне не изменяет память.
При этом для сборки библиотек, которые необходимо собирать, необходимо выполнить одни и те же действия в консоли:
- Для Intel Compiler это будет в соответствующем Command Prompt.
- Для Visual Studio это будет в соответствующем Command Prompt.
- Для MinGW это будет в обычной консоли, если, конечно, путь к bin в MinGW у Вас добавлен в переменную среды PATH.
Действия надо выполнить одни и те же. Сначала bootstrap.bat , а потом b2 —help .
В хелпе b2 Вы увидите все варианты настройки сборки, чтобы собрать наиболее удобным Вам образом.
Строчка будет выглядеть так:
b2 параметр1 параметр2 параметр3 .
- toolset — его стоит указать, чтобы сборка производилась конкретным компилятором (gcc, intel, visual studio), причем можно указать и версию компилятора.
- variant, вид сборки, debug или release. Для разработки Вам понадобятся оба варианта.
- link — Вы выбираете, будет Ваш бинарный код обращаться в dll или содержать «в себе» все используемые алгоритмы.
- threading — честно говоря, плохо понимаю смысл этой директивы и всегда указываю multi. Редко мы пишем однопоточные приложения.
- runtime-link — то же, что и link, только для рантайма.
- address-model — параметр не указан в хелпе, но помогает выбрать архитектуру собираемых библиотек.
- stage/install, отличаются лишь тем, что install позволит «выгрузить» только нужное в отдельную папку, stage собирает всё туда, где оно есть. Если Вы не увлекаетесь изменениями исходников boost, stage Вам вполне подойдет.
В итоге получается что-то вроде вот такого:
Для дебага в x32 и такого:
Для релиза в x32.
Ждете около 40 минут, радуетесь результату. В случае проблем — гуглите, скорее всего уже тысячи людей сталкивались с Вашей проблемой, и ее решение — невнимательность или какие-то специфические настройки чего-нибудь. Например, при сборке boost python вылезает много warning-ов на MinGW из-за конфликта хедеров, подобные вещи можно разрулить в частном порядке.
Потратив 2 часа на то, чтобы один раз в этом разобраться, Вы никогда не будете зависеть ни от каких сторонних сборок, будете понимать, где у Вас что лежит, кто туда положил и т.п. В общем, это полезно.
kaktusenok
Опишем, как установить библиотеку Boost для среды Visual Studio.
Шаг 1. Скачиваем исходные коды
Как правило, используется последняя версия библиотеки Boost. Если вам нужна более ранняя версия, то следует учитывать, что компилятор VS 2012 поддерживается с версии 1.52. Другими словами, вы не сможете использовать версию более раннюю чем 1.52 на VS 2012. Придётся установить более раннюю версию VS.
Ссылку на последнюю версию можно найти на странице http://www.boost.org/users/download. Обычно это ссылка ведёт на репозиторий вида http://sourceforge.net/projects/boost/files/boost/1.54.0/, откуда скачивается файл с именем boost_1_54_0.zip или другим в зависимости от версии.
Я буду выполнять установку библиотеки в папку d:\Projects\Libs\boost_1_54_0\. Если у вас другая папка, то все команды изменяются соответствующим образом.
Распаковываем архив boost_1_54_0.zip в папку d:\Projects\Libs\boost_1_54_0\. Из командного интерпретатора выполним следующие команды:
Если требуется изменить конфигурацию библиотеки, то именно сейчас нужно изменить файл ‘project-config.jam’. Если вы не знаете об этом, то оставляйте файл конфигурации как есть.
Далее запускаем процесс компиляции, введя команду b2.
Процесс компиляции длится около 20 минут. В конце отобразится информации о путях подключения библиотеки:
Можно использовать утилиту BlueGo, которая позволяет упростить процесс компиляции.
Шаг 3. Создание символьной ссылки
Поскольку будут выходить новые версии библиотеки, то каждый раз изменять пути с D:\Projects\Libs\boost_1_54_0\stage\lib на D:\Projects\Libs\boost_1_55_0\stage\lib и т.д. будет несколько утомительно.
Я предлагаю использовать символьные ссылки, а точнее точки соединения для папок:
Далее я буду использовать D:\Projects\Libs\boost вместо D:\Projects\Libs\boost_1_54_0.
Шаг 4. Создание проекта в Visual Studio
Заходим в свойства проекта и изменяем:
- в элемент «Каталоги включения» добавляем «d:\Projects\Libs\boost»;
- в элемент «Каталоги библиотек» добавляем «d:\Projects\Libs\boost\libs»;
- в элемент «Дополнительные каталоги библиотек» добавляем «d:\Projects\Libs\boost_1_54_0\stage\lib»;
- в элемент «Дополнительные зависимости» добавляем
libboost_atomic-vc110-mt-gd-1_54.lib
libboost_chrono-vc110-mt-gd-1_54.lib
libboost_context-vc110-mt-gd-1_54.lib
libboost_coroutine-vc110-mt-gd-1_54.lib
libboost_date_time-vc110-mt-gd-1_54.lib
libboost_exception-vc110-mt-gd-1_54.lib
libboost_filesystem-vc110-mt-gd-1_54.lib
libboost_graph-vc110-mt-gd-1_54.lib
libboost_iostreams-vc110-mt-gd-1_54.lib
libboost_locale-vc110-mt-gd-1_54.lib
libboost_log-vc110-mt-gd-1_54.lib
libboost_log_setup-vc110-mt-gd-1_54.lib
libboost_math_c99-vc110-mt-gd-1_54.lib
libboost_math_c99f-vc110-mt-gd-1_54.lib
libboost_math_c99l-vc110-mt-gd-1_54.lib
libboost_math_tr1-vc110-mt-gd-1_54.lib
libboost_math_tr1f-vc110-mt-gd-1_54.lib
libboost_math_tr1l-vc110-mt-gd-1_54.lib
libboost_prg_exec_monitor-vc110-mt-gd-1_54.lib
libboost_program_options-vc110-mt-gd-1_54.lib
libboost_random-vc110-mt-gd-1_54.lib
libboost_regex-vc110-mt-gd-1_54.lib
libboost_serialization-vc110-mt-gd-1_54.lib
libboost_signals-vc110-mt-gd-1_54.lib
libboost_system-vc110-mt-gd-1_54.lib
libboost_test_exec_monitor-vc110-mt-gd-1_54.lib
libboost_thread-vc110-mt-gd-1_54.lib
libboost_timer-vc110-mt-gd-1_54.lib
libboost_unit_test_framework-vc110-mt-gd-1_54.lib
libboost_wave-vc110-mt-gd-1_54.lib
libboost_wserialization-vc110-mt-gd-1_54.lib
- в элемент «Дополнительные зависимости» добавляем
libboost_atomic-vc110-mt-1_54.lib
libboost_chrono-vc110-mt-1_54.lib
libboost_context-vc110-mt-1_54.lib
libboost_coroutine-vc110-mt-1_54.lib
libboost_date_time-vc110-mt-1_54.lib
libboost_exception-vc110-mt-1_54.lib
libboost_filesystem-vc110-mt-1_54.lib
libboost_graph-vc110-mt-1_54.lib
libboost_iostreams-vc110-mt-1_54.lib
libboost_locale-vc110-mt-1_54.lib
libboost_log_setup-vc110-mt-1_54.lib
libboost_log-vc110-mt-1_54.lib
libboost_math_c99f-vc110-mt-1_54.lib
libboost_math_c99l-vc110-mt-1_54.lib
libboost_math_c99-vc110-mt-1_54.lib
libboost_math_tr1f-vc110-mt-1_54.lib
libboost_math_tr1l-vc110-mt-1_54.lib
libboost_math_tr1-vc110-mt-1_54.lib
libboost_prg_exec_monitor-vc110-mt-1_54.lib
libboost_program_options-vc110-mt-1_54.lib
libboost_random-vc110-mt-1_54.lib
libboost_regex-vc110-mt-1_54.lib
libboost_serialization-vc110-mt-1_54.lib
libboost_signals-vc110-mt-1_54.lib
libboost_system-vc110-mt-1_54.lib
libboost_test_exec_monitor-vc110-mt-1_54.lib
libboost_thread-vc110-mt-1_54.lib
libboost_timer-vc110-mt-1_54.lib
libboost_unit_test_framework-vc110-mt-1_54.lib
libboost_wave-vc110-mt-1_54.lib
libboost_wserialization-vc110-mt-1_54.lib
Теперь проект успешно компилируется:
7 комментариев:
Серьезность Код Описание Проект Файл Строка
Ошибка LNK1181 не удается открыть входной файл "libboost_atomic-vc110-mt-1_54.lib" VStilsofteServer E:\Progect VisualStudio 2015\VStilsofteServer\VStilsofteServer\LINK
Почему у меня выдает такую ошибку
Необходимо добавить в Linker->Additional library directories
путь к boost_x_xx\stage\lib, где x — версия буста
Чтобы не набирать библиотеки из папки вручную или через cmd, кому нужен список библиотек версии 1_68 для вставки во вкладку "Дополнительные библиотеки" новой версии — вот он:
Debug (Активный):
libboost_atomic-vc140-mt-gd-x32-1_68.lib
libboost_atomic-vc140-mt-gd-x64-1_68.lib
libboost_chrono-vc140-mt-gd-x32-1_68.lib
libboost_chrono-vc140-mt-gd-x64-1_68.lib
libboost_container-vc140-mt-gd-x32-1_68.lib
libboost_container-vc140-mt-gd-x64-1_68.lib
libboost_context-vc140-mt-gd-x32-1_68.lib
libboost_context-vc140-mt-gd-x64-1_68.lib
libboost_contract-vc140-mt-gd-x32-1_68.lib
libboost_contract-vc140-mt-gd-x64-1_68.lib
libboost_coroutine-vc140-mt-gd-x32-1_68.lib
libboost_coroutine-vc140-mt-gd-x64-1_68.lib
libboost_date_time-vc140-mt-gd-x32-1_68.lib
libboost_date_time-vc140-mt-gd-x64-1_68.lib
libboost_exception-vc140-mt-gd-x32-1_68.lib
libboost_exception-vc140-mt-gd-x64-1_68.lib
libboost_fiber-vc140-mt-gd-x32-1_68.lib
libboost_fiber-vc140-mt-gd-x64-1_68.lib
libboost_filesystem-vc140-mt-gd-x32-1_68.lib
libboost_filesystem-vc140-mt-gd-x64-1_68.lib
libboost_graph-vc140-mt-gd-x32-1_68.lib
libboost_graph-vc140-mt-gd-x64-1_68.lib
libboost_iostreams-vc140-mt-gd-x32-1_68.lib
libboost_iostreams-vc140-mt-gd-x64-1_68.lib
libboost_locale-vc140-mt-gd-x32-1_68.lib
libboost_locale-vc140-mt-gd-x64-1_68.lib
libboost_log_setup-vc140-mt-gd-x32-1_68.lib
libboost_log_setup-vc140-mt-gd-x64-1_68.lib
libboost_log-vc140-mt-gd-x32-1_68.lib
libboost_log-vc140-mt-gd-x64-1_68.lib
libboost_math_c99f-vc140-mt-gd-x32-1_68.lib
libboost_math_c99f-vc140-mt-gd-x64-1_68.lib
libboost_math_c99l-vc140-mt-gd-x32-1_68.lib
libboost_math_c99l-vc140-mt-gd-x64-1_68.lib
libboost_math_c99-vc140-mt-gd-x32-1_68.lib
libboost_math_c99-vc140-mt-gd-x64-1_68.lib
libboost_math_tr1f-vc140-mt-gd-x32-1_68.lib
libboost_math_tr1f-vc140-mt-gd-x64-1_68.lib
libboost_math_tr1l-vc140-mt-gd-x32-1_68.lib
libboost_math_tr1l-vc140-mt-gd-x64-1_68.lib
libboost_math_tr1-vc140-mt-gd-x32-1_68.lib
libboost_math_tr1-vc140-mt-gd-x64-1_68.lib
libboost_prg_exec_monitor-vc140-mt-gd-x32-1_68.lib
libboost_prg_exec_monitor-vc140-mt-gd-x64-1_68.lib
libboost_program_options-vc140-mt-gd-x32-1_68.lib
libboost_program_options-vc140-mt-gd-x64-1_68.lib
libboost_random-vc140-mt-gd-x32-1_68.lib
libboost_random-vc140-mt-gd-x64-1_68.lib
libboost_regex-vc140-mt-gd-x32-1_68.lib
libboost_regex-vc140-mt-gd-x64-1_68.lib
libboost_serialization-vc140-mt-gd-x32-1_68.lib
libboost_serialization-vc140-mt-gd-x64-1_68.lib
libboost_signals-vc140-mt-gd-x32-1_68.lib
libboost_signals-vc140-mt-gd-x64-1_68.lib
libboost_stacktrace_noop-vc140-mt-gd-x32-1_68.lib
libboost_stacktrace_noop-vc140-mt-gd-x64-1_68.lib
libboost_stacktrace_windbg_cached-vc140-mt-gd-x32-1_68.lib
libboost_stacktrace_windbg_cached-vc140-mt-gd-x64-1_68.lib
libboost_stacktrace_windbg-vc140-mt-gd-x32-1_68.lib
libboost_stacktrace_windbg-vc140-mt-gd-x64-1_68.lib
libboost_system-vc140-mt-gd-x32-1_68.lib
libboost_system-vc140-mt-gd-x64-1_68.lib
libboost_test_exec_monitor-vc140-mt-gd-x32-1_68.lib
libboost_test_exec_monitor-vc140-mt-gd-x64-1_68.lib
libboost_thread-vc140-mt-gd-x32-1_68.lib
libboost_thread-vc140-mt-gd-x64-1_68.lib
libboost_timer-vc140-mt-gd-x32-1_68.lib
libboost_timer-vc140-mt-gd-x64-1_68.lib
libboost_type_erasure-vc140-mt-gd-x32-1_68.lib
libboost_type_erasure-vc140-mt-gd-x64-1_68.lib
libboost_unit_test_framework-vc140-mt-gd-x32-1_68.lib
libboost_unit_test_framework-vc140-mt-gd-x64-1_68.lib
libboost_wave-vc140-mt-gd-x32-1_68.lib
libboost_wave-vc140-mt-gd-x64-1_68.lib
libboost_wserialization-vc140-mt-gd-x32-1_68.lib
libboost_wserialization-vc140-mt-gd-x64-1_68.lib
Это для версии 1_68. Список, как видите очень расширился!
Этот комментарий был удален автором.
Так как предоставленные автором имена библиотек тяжело модифицировать под имена библиотек новых версий libboost (так как в имена добавлена приставка x32 или x64, в именах библиотек автора их нет, следовательно в блокноте уже тяжело как-то изменять. ), я выложил список новых библиотек. Я не хочу тут спамить, чтобы получить список для Release, зайдите в блокнот, скопируйте все библиотеки для Debug (Активный), я выкладывал в предыдущем комментарии ,перейдите в меню -> "Правка" -> "Заменить". В поле "Что" пишите "-gd" (без кавычек), поле "Чем" оставьте пустым. Потом нажимаете "Заменить всё". Получившийся список имён библиотек копируете в "Дополнительные библиотеки" в режиме Release.