Как установить boost ubuntu

Как установить Boost на Ubuntu

Я на Ubuntu, и я хочу установить Boost. Я пробовал с

но такого пакета не было. Каков наилучший способ установить Boost на Ubuntu?

6 ответов

можно использовать (требуется sudo )

или вы можете позвонить

получить версию Boost, что вам требуется. Это для 1.55, но не стесняйтесь изменять или вручную загружать себя:

получить необходимые библиотеки, основные из них icu на boost::regex поддержка:

тогда постройте его с помощью:

и в конечном итоге установить его:

установка Boost на Ubuntu с примером использования boost::array :

установить libboost-all-dev и aptitude:

вставьте это в файл c++ под названием main.cpp :

скомпилировать следующим образом:

получить версию Boost, что вам требуется. Это для 1.55, но не стесняйтесь изменять или вручную загружать себя:

получить необходимые библиотеки, основными из них являются icu для boost:: regex поддержка:

если мы хотим MPI, то нам нужно установить флаг в user-config.файл джем:

найти максимальное количество физических ядер:

установить boost в параллель:

предполагает / usr / local / lib уже настройка. если нет, то вы можете добавить его в свой ПУТЬ К БИБЛИОТЕКЕ LD:

обновление для приложения Windows 10 Ubuntu через подсистему (также работает на стандартном Ubuntu):

у вас могут возникнуть проблемы с поиском пакета. Если вы это сделаете, не бойтесь! ППА здесь!

Источник

How to Install Boost on Ubuntu 16.04/18.04 Linux

This post will guide you how to install Boost libraries on Ubunt 16.04/18.04 Linux server. How do I install Boost C++ libraries 1.64 from a PPA in Ubuntu. How to install Boost from the default repositories on Ubuntu 16.04/18.04 Linux. How to install the latest version of Boost libraries from source package on Ubuntu Linux server.

What is Boost?

Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. It contains over eighty individual libraries.

Install Boost C++ libraries via Default Repository

Boost is available on the default Ubuntu repositories, so you can install it with apt command directly, type the following commmand:

Verify the installed Boost Version

Once completed the installation process of Boost on your Ubuntu server, you can verify the installed boost version to check if the Boost is installed properly. Type one of the following commands to check version of boost:

Install Boost C++ libraries From PPA

You can also install Boost from a PPA on Ubuntu Linux, just type the following command:

This PPA can be added to your system manually by copying the lines below and adding them to your system’s software sources.

For Ubuntu 18.04:

For Ubuntu 18.10:

For Ubuntu 16.04:

Then you can try to install the Boost on your Ubuntu Linux, and the latest version of this PPA is 1.68, type the following command to install it:

Then the latest version 1.68 of boost would be installed on your Ubuntu Linux server.

Install Boost C++ libraries From Source Package

#1 download source package of boost from this link with wget tool, type:

#2 extract all files from the archive file that you downloaded in the above step. type:

#3 Change the current directory to boost_1_69_0/, type:

#4 execute the script bootstrap.sh, type the following command:

#5 Builds and installs Boost with the following command:

Conclusion

You should know that how to install Boost C++ Libraries on your Ubuntu 16.04 or 18.04 Linux from this guide. And if you want to learn more about the Boost, you can go the below official web site to checking the getting started guide directly.

Источник

. one of the most highly regarded and expertly designed C++ library projects in the world. — Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Как установить boost ubuntu. Смотреть фото Как установить boost ubuntu. Смотреть картинку Как установить boost ubuntu. Картинка про Как установить boost ubuntu. Фото Как установить boost ubuntu Getting Started on Unix Variants

1 Get Boost

The most reliable way to get a copy of Boost is to download a distribution from SourceForge:

In the directory where you want to put the Boost installation, execute

RedHat, Debian, and other distribution packagers supply Boost library packages, however you may need to adapt these instructions if you use third-party packages, because their creators usually choose to break Boost up into several packages, reorganize the directory structure of the Boost distribution, and/or rename the library binaries. 1 If you have any trouble, we suggest using an official Boost distribution from SourceForge.

2 The Boost Distribution

This is a sketch of the resulting directory structure:

The organization of Boost library headers isn’t entirely uniform, but most libraries follow a few patterns:

Some older libraries and most very small libraries place all public headers directly into boost /.

Most libraries’ public headers live in a subdirectory of boost /, named after the library. For example, you’ll find the Python library’s def.hpp header in

Some libraries have an “aggregate header” in boost / that #includes all of the library’s other headers. For example, Boost.Python’s aggregate header is

Most libraries place private headers in a subdirectory called detail /, or aux_ /. Don’t expect to find anything you can use in these directories.

It’s important to note the following:

To compile anything in Boost, you need a directory containing the boost / subdirectory in your #include path.

depending on your preference regarding the use of angle bracket includes.

Don’t be distracted by the doc / subdirectory; it only contains a subset of the Boost documentation. Start with libs / index.html if you’re looking for the whole enchilada.

3 Header-Only Libraries

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.

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 must be built separately are:

A few libraries have optional separately-compiled binaries:

4 Build a Simple Program Using Boost

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:

Copy the text of this program into a file called example.cpp.

Now, in the directory where you saved example.cpp, issue the following command:

To test the result, type:

4.1 Errors and Warnings

Don’t be alarmed if you see compiler warnings originating in Boost headers. We try to eliminate them, but doing so isn’t always practical. 3 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.

5 Prepare to Use a Boost Library Binary

If you want to use any of the separately-compiled Boost libraries, you’ll need to acquire library binaries.

5.1 Easy Build and Install

will leave Boost binaries in the lib/ subdirectory of 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.

5.2 Or, Build Custom Binaries

If you’re using a compiler other than your system’s default, you’ll need to use Boost.Build to create binaries.

You’ll also use this method if you need a nonstandard build variant (see the Boost.Build documentation for more details).

5.2.1 Install Boost.Build

Boost.Build is a text-based system for developing, testing, and installing software. First, you’ll need to build and install it. To do this:

5.2.2 Identify Your Toolset

First, find the toolset corresponding to your compiler in the following table (an up-to-date list is always available in the Boost.Build documentation).

If you previously chose a toolset for the purposes of building b2, you should assume it won’t work and instead choose newly from the table below.

5.2.3 Select a Build Directory

Boost.Build will place all intermediate files it generates while building into the build directory. If your Boost root directory is writable, this step isn’t strictly necessary: by default Boost.Build will create a bin.v2/ subdirectory for that purpose in your current working directory.

5.2.4 Invoke b2

Change your current directory to the Boost root directory and invoke b2 as follows:

For a complete description of these and other invocation options, please see the Boost.Build documentation.

For example, your session might look like this:

b2 is case-sensitive; it is important that all the parts shown in bold type above be entirely lower-case.

For a description of other options you can pass when invoking b2, type:

In particular, to limit the amount of time spent building, you may be interested in:

Boost.Build can produce a great deal of output, which can make it easy to miss problems. If you want to make sure everything is went well, you might redirect the output into a file by appending “ >build.log 2>&1 ” to your command line.

5.3 Expected Build Output

During the process of building Boost libraries, you can expect to see some messages printed on the console. These may include

Notices about Boost library configuration—for example, the Regex library outputs a message about ICU when built without Unicode support, and the Python library may be skipped without error (but with a notice) if you don’t have Python installed.

Messages from the build tool that report the number of targets that were built or skipped. Don’t be surprised if those numbers don’t make any sense to you; there are many targets per library.

Build action messages describing what the tool is doing, which look something like:

5.4 In Case of Build Errors

The only error messages you see when building Boost—if any—should be related to the IOStreams library’s support of zip and bzip2 formats as described here. Install the relevant development packages for libz and libbz2 if you need those features. Other errors when building Boost libraries are cause for concern.

If it seems like the build system can’t find your compiler and/or linker, consider setting up a user-config.jam file as described here. If that isn’t your problem or the user-config.jam file doesn’t work for you, please address questions about configuring Boost for your compiler to the Boost.Build mailing list.

6 Link Your Program to a Boost Library

To demonstrate linking with a Boost binary library, we’ll use the following simple program that extracts the subject lines from emails. It uses the Boost.Regex library, which has a separately-compiled binary component.

There are two main challenges associated with linking:

There are two main ways to link to libraries:

You can specify the full path to each library:

In both cases above, the bold text is what you’d add to the command lines we explored earlier.

6.1 Library Naming

In order to choose the right binary for your build configuration you need to know how Boost binaries are named. Each library filename is composed of a common sequence of elements that describe how it was built. For example, libboost_regex-vc71-mt-d-x86-1_34.lib can be broken down into the following elements:

ABI tag: encodes details that affect the library’s interoperability with other compiled code. For each such feature, a single letter is added to the tag:

KeyUse this library when:Boost.Build option
slinking statically to the C++ standard library and compiler runtime support libraries.runtime-link=static
gusing debug versions of the standard and runtime support libraries.runtime-debugging=on
yusing a special debug build of Python.python-debugging=on
dbuilding a debug version of your code. 5variant=debug
pusing the STLPort standard library rather than the default one supplied with your compiler.stdlib=stlport

Architecture and address model tag: in the first letter, encodes the architecture as follows:

KeyArchitectureBoost.Build option
xx86-32, x86-64architecture=x86
aARMarchitecture=arm
iIA-64architecture=ia64
sSparcarchitecture=sparc
mMIPS/SGIarchitecture=mips*
pRS/6000 & PowerPCarchitecture=power

The two digits following the letter encode the address model as follows:

KeyAddress modelBoost.Build option
3232 bitaddress-model=32
6464 bitaddress-model=64

6.2 Test Your Program

To test our subject extraction, we’ll filter the following text file. Copy it out of your browser and save it as jayne.txt:

On csh and tcsh, it’s

Once the necessary variable (if any) is set, you can run your program as follows:

The program should respond with the email subject, “Will Success Spoil Rock Hunter?”

7 Conclusion and Further Resources

This concludes your introduction to Boost and to integrating it with your programs. As you start using Boost in earnest, there are surely a few additional points you’ll wish we had covered. One day we may have a “Book 2 in the Getting Started series” that addresses them. Until then, we suggest you pursue the following resources. 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.

Источник

. one of the most highly regarded and expertly designed C++ library projects in the world. — Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Как установить boost ubuntu. Смотреть фото Как установить boost ubuntu. Смотреть картинку Как установить boost ubuntu. Картинка про Как установить boost ubuntu. Фото Как установить boost ubuntu Getting Started on Unix Variants

1 Get Boost

The most reliable way to get a copy of Boost is to download a distribution from SourceForge:

In the directory where you want to put the Boost installation, execute

RedHat, Debian, and other distribution packagers supply Boost library packages, however you may need to adapt these instructions if you use third-party packages, because their creators usually choose to break Boost up into several packages, reorganize the directory structure of the Boost distribution, and/or rename the library binaries. 1 If you have any trouble, we suggest using an official Boost distribution from SourceForge.

2 The Boost Distribution

This is a sketch of the resulting directory structure:

The organization of Boost library headers isn’t entirely uniform, but most libraries follow a few patterns:

Some older libraries and most very small libraries place all public headers directly into boost /.

Most libraries’ public headers live in a subdirectory of boost /, named after the library. For example, you’ll find the Python library’s def.hpp header in

Some libraries have an “aggregate header” in boost / that #includes all of the library’s other headers. For example, Boost.Python’s aggregate header is

Most libraries place private headers in a subdirectory called detail /, or aux_ /. Don’t expect to find anything you can use in these directories.

It’s important to note the following:

To compile anything in Boost, you need a directory containing the boost / subdirectory in your #include path.

depending on your preference regarding the use of angle bracket includes.

Don’t be distracted by the doc / subdirectory; it only contains a subset of the Boost documentation. Start with libs / index.html if you’re looking for the whole enchilada.

3 Header-Only Libraries

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.

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 must be built separately are:

A few libraries have optional separately-compiled binaries:

4 Build a Simple Program Using Boost

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:

Copy the text of this program into a file called example.cpp.

Now, in the directory where you saved example.cpp, issue the following command:

To test the result, type:

4.1 Errors and Warnings

Don’t be alarmed if you see compiler warnings originating in Boost headers. We try to eliminate them, but doing so isn’t always practical. 3 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.

5 Prepare to Use a Boost Library Binary

If you want to use any of the separately-compiled Boost libraries, you’ll need to acquire library binaries.

5.1 Easy Build and Install

will leave Boost binaries in the lib/ subdirectory of 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.

5.2 Or, Build Custom Binaries

If you’re using a compiler other than your system’s default, you’ll need to use Boost.Build to create binaries.

You’ll also use this method if you need a nonstandard build variant (see the Boost.Build documentation for more details).

5.2.1 Install Boost.Build

Boost.Build is a text-based system for developing, testing, and installing software. First, you’ll need to build and install it. To do this:

5.2.2 Identify Your Toolset

First, find the toolset corresponding to your compiler in the following table (an up-to-date list is always available in the Boost.Build documentation).

If you previously chose a toolset for the purposes of building b2, you should assume it won’t work and instead choose newly from the table below.

5.2.3 Select a Build Directory

Boost.Build will place all intermediate files it generates while building into the build directory. If your Boost root directory is writable, this step isn’t strictly necessary: by default Boost.Build will create a bin.v2/ subdirectory for that purpose in your current working directory.

5.2.4 Invoke b2

Change your current directory to the Boost root directory and invoke b2 as follows:

For a complete description of these and other invocation options, please see the Boost.Build documentation.

For example, your session might look like this:

b2 is case-sensitive; it is important that all the parts shown in bold type above be entirely lower-case.

For a description of other options you can pass when invoking b2, type:

In particular, to limit the amount of time spent building, you may be interested in:

Boost.Build can produce a great deal of output, which can make it easy to miss problems. If you want to make sure everything is went well, you might redirect the output into a file by appending “ >build.log 2>&1 ” to your command line.

5.3 Expected Build Output

During the process of building Boost libraries, you can expect to see some messages printed on the console. These may include

Notices about Boost library configuration—for example, the Regex library outputs a message about ICU when built without Unicode support, and the Python library may be skipped without error (but with a notice) if you don’t have Python installed.

Messages from the build tool that report the number of targets that were built or skipped. Don’t be surprised if those numbers don’t make any sense to you; there are many targets per library.

Build action messages describing what the tool is doing, which look something like:

5.4 In Case of Build Errors

The only error messages you see when building Boost—if any—should be related to the IOStreams library’s support of zip and bzip2 formats as described here. Install the relevant development packages for libz and libbz2 if you need those features. Other errors when building Boost libraries are cause for concern.

If it seems like the build system can’t find your compiler and/or linker, consider setting up a user-config.jam file as described here. If that isn’t your problem or the user-config.jam file doesn’t work for you, please address questions about configuring Boost for your compiler to the Boost.Build mailing list.

6 Link Your Program to a Boost Library

To demonstrate linking with a Boost binary library, we’ll use the following simple program that extracts the subject lines from emails. It uses the Boost.Regex library, which has a separately-compiled binary component.

There are two main challenges associated with linking:

There are two main ways to link to libraries:

You can specify the full path to each library:

In both cases above, the bold text is what you’d add to the command lines we explored earlier.

6.1 Library Naming

In order to choose the right binary for your build configuration you need to know how Boost binaries are named. Each library filename is composed of a common sequence of elements that describe how it was built. For example, libboost_regex-vc71-mt-d-1_34.lib can be broken down into the following elements:

ABI tag: encodes details that affect the library’s interoperability with other compiled code. For each such feature, a single letter is added to the tag:

KeyUse this library when:Boost.Build option
slinking statically to the C++ standard library and compiler runtime support libraries.runtime-link=static
gusing debug versions of the standard and runtime support libraries.runtime-debugging=on
yusing a special debug build of Python.python-debugging=on
dbuilding a debug version of your code. 5variant=debug
pusing the STLPort standard library rather than the default one supplied with your compiler.stdlib=stlport

6.2 Test Your Program

To test our subject extraction, we’ll filter the following text file. Copy it out of your browser and save it as jayne.txt:

On csh and tcsh, it’s

Once the necessary variable (if any) is set, you can run your program as follows:

The program should respond with the email subject, “Will Success Spoil Rock Hunter?”

7 Conclusion and Further Resources

This concludes your introduction to Boost and to integrating it with your programs. As you start using Boost in earnest, there are surely a few additional points you’ll wish we had covered. One day we may have a “Book 2 in the Getting Started series” that addresses them. Until then, we suggest you pursue the following resources. 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.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *