Установка boost на linux

How to install Boost on Ubuntu

find packages you need and install them using the apt-get command.

I had programming experience with boost, but not installation experience. I have never tried this myself, so I can’t say if it is easy to use (but it seems to me that package manager is the easiest way). I should have posted this suggestion as a comment, but I can’t comment questions.

The one disadvantage of using apt-get is that it is usually a couple of version behind the latest boost release.

It is easy to build and install Boost from the sources, for example anycoder.wordpress.com/2014/04/28/building-boost

Do not use the packaged version of boost, right now on Ubuntu 16.04 it’s 1.58, and the latest stable version is 1.67.0 ! See the response and my comment below : stackoverflow.com/a/41272796/2617716

Get the version of Boost that you require. This is for 1.55 but feel free to change or manually download yourself:

wget -O boost_1_55_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download tar xzvf boost_1_55_0.tar.gz cd boost_1_55_0/ 

Get the required libraries, main ones are icu for boost::regex support:

sudo apt-get update sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev libboost-all-dev 

and eventually install it:

What will be the difference if we use ./bootstrap.sh —prefix=/usr/include ? I have the boost library in /usr/include. I was wondering that by doing this, can I replace my old installation ?

@tbc0 Boost is at version 1.59 now, and the latest PPA is at 1.55, so building from source is relevant

Installing Boost on Ubuntu with an example of using boost::array :

Install libboost-all-dev and aptitude:

sudo apt install libboost-all-dev sudo apt install aptitude aptitude search boost 

Then paste this into a C++ file called main.cpp :

#include #include using namespace std; int main() < boost::arrayarr = >; cout

adding »

Get the version of Boost that you require. This is for 1.55 but feel free to change or manually download yourself (Boost download page):

wget -O boost_1_55_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download tar xzvf boost_1_55_0.tar.gz cd boost_1_55_0/

Get the required libraries, main ones are icu for boost::regex support:

sudo apt-get update sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev
./bootstrap.sh --prefix=/usr/local

If we want MPI then we need to set the flag in the user-config.jam file:

user_configFile=`find $PWD -name user-config.jam` echo "using mpi ;" >> $user_configFile

Find the maximum number of physical cores:

n=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk ''`

Install boost in parallel:

sudo ./b2 --with=all -j $n install

Assumes you have /usr/local/lib setup already. if not, you can add it to your LD LIBRARY PATH:

sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf'

Some things such as PO Edit 2.0 require boost 1.6, which is not available at this time via apt-get you can get this from boost.org/users/history/version_1_60_0.html and then expand it. Follow the excellent instructions above, remembering that LD Library Path is not the same as $PATH

Читайте также:  How to install games on linux

Comment from a recent installation, to get the latest version : — Go to boost.org and «Current release» downloads to get the last one (currently 1.67.0 : dl.bintray.com/boostorg/release/1.67.0/source/…) Thanks !

old link to sourceforge is not working. use dl.bintray.com/boostorg/release/1.72.0/source/… (with needed version)

An update for Windows 10 Ubuntu Application via Subsystem (also works on standard Ubuntu):

You might have problems finding the package. If you do, never fear! PPA is here!

sudo add-apt-repository ppa:boost-latest/ppa sudo apt-get update 
sudo apt-get install libboost-all-dev 

I’m aware, posting for those (Like me) who were looking for a rounded solution. Similar to Алексей Штыков’s Answer

@AdrianW this answer isn’t about Windows 10. It’s about Ubuntu that happens to be running on a Windows 10 kernel, so it’s a valid solution to those running Ubuntu in some way. Since the question didn’t limit it to Ubuntu running on a Linux kernel specifically, this solution is fine.

The repository ‘ppa.launchpad.net/boost-latest/ppa/ubuntu xenial Release’ does not have a Release file.

I am having following erro: E: The repository ‘http://ppa.launchpad.net/boost-latest/ppa/ubuntu focal Release’ does not have a Release file.

You can install boost on ubuntu by using the following commands:

sudo apt install libboost-all-dev

$ sudo apt-get install libboost* 

You may get an error message similar to the following, like I did:

E: Unable to correct problems, you have held broken packages. 

Then try install below package:

$ sudo apt-get install libboost-all-dev 

Now you can create a a sample project utilizing Boost:

$ mkdir boost $ cd boost/ $ cat > main.cpp & 

Actually you don’t need «install» or «compile» anything before using Boost in your project. You can just download and extract the Boost library to any location on your machine, which is usually like /usr/local/ .

When you compile your code, you can just indicate the compiler where to find the libraries by -I . For example, g++ -I /usr/local/boost_1_59_0 xxx.hpp .

This would only work for header libraries of boost. The rest of them would need to be built or installed using a package manager as described in the above answers. The boost libraries that require separate building and installation are the following: atomic, chrono, container, context, coroutine, coroutine2, date_time, exception, filesystem, graph, graph_parallel, iostreams, locale, log, math, mpi, program_options, python, random, regex, serialization, signals, system, test, thread, timer, type_erasure, wave.

Читайте также:  Truncating log file linux

Even repairing this solution by following Elias Kouskoumvekakis’s further instructions would be a bad idea (unless you have a good reason), since package managers add the ability to very easily update Boost to newer versions (in Ubuntu, just a sudo apt update; sudo apt upgrade to upgrade all your packages to the latest versions in the repositories) if you find the appropriate package repository for Boost and to very easily delete Boost from the system if you want to. The manual approach makes those tasks harder, so you need a good reason to skip out on the benefits of a package manager.

Also, installing without a package manager is better covered in an earlier answer, which includes necessary building instructions.

Источник

How to install Boost on Ubuntu 22.04

How to install Boost on Ubuntu 22.04 2

Boost is a mighty C++ library used by many developers to provide various functions. If you’re on Ubuntu 22.04 and want to install Boost, follow these steps.

The Boost C++ libraries are a group of C++ libraries that are open-source and offer support for common tasks and functionalities in C++ programming. These libraries are widely used and respected by C++ developers and can be found in many applications and software projects.

The Boost libraries are user-friendly and easy to implement, with the added benefit of being well-documented and portable. They are released under the Boost Software License, which permits their usage in both commercial and open-source projects. These libraries cover a broad spectrum of topics, including data structures, algorithms, utilities, and many more.

First, use the apt package manager to install the necessary packages and dependencies. Then, choose to install Boost from Ubuntu repositories or source code. The source code option allows customization but requires more time and effort. Conversely, installing from Ubuntu repositories is quicker and simpler.

If you opt for the first method, you won’t get the newest version of the library, but the installation process will be quick and easy. For those who don’t need the latest release, the first option is a suitable choice. If you prefer the latest version, use the source method to install Boost libraries on your system.

This guide will walk you through both methods to help you successfully install Boost on Ubuntu 22.04.

How to install the Boost library from the repository of Ubuntu 22.04

First , ensure that your computer is up-to-date and that the APT package manager has the most recent package index cache:

sudo apt update && sudo apt upgrade

To begin the installation process, enter the command below into your terminal and wait for it to finish:

Читайте также:  Debian install linux header

sudo apt install libboost-all-dev

How to install Boost on Ubuntu 22.04 3

Installing the Boost Library from the Source Package

This method will help you install the Boost library on your Ubuntu computer, but you’ll end up with an older version than the latest one available. Let’s dive right into the steps you’ll need to take.

To start, you’ll need to download the most recent release of Boost from the official website. Alternatively, you can also grab it from the Boost Github release section .

After the pages finish loading, you’ll want to click on the “ Download ” button, which will take you to the index page. There, you’ll be able to find libraries available in various compressions.

As of right now, the most recent version of these instructions is 1.81.0. For this article, I’ll be downloading boost_1_81_0.tar.gz, but there are other compressed files available if you prefer them.

After you’ve finished downloading the file, navigate to the directory where it’s located and extract it using the tar command provided below. If you downloaded boost_1_81_0_.tar.gz, this is the command you’ll need to use.

tar xvf boost_1_81_0.tar.gz

Once the libraries are extracted, they can be used with your project as a portable resource. Be sure to remember the directory where the libraries were extracted.

If you prefer to use the Command terminal to download the file, you can use the “wget” command followed by the URL of the file. To get the URL of the Tar file, simply right-click on it and choose “Copy Address” :

Once you’ve used the command mentioned in the previous step to extract the files, you can change to the extracted directory by entering the “cd” command followed by the name of the directory, which in this case would be “boost_1_81_0”.

Setting up Boost’s bootstrap

Once you’ve completed the previous step, proceed by running the given command to initiate the Bootstrap script that is located within the Boost extracted folder. This script will begin the process of building a B2 engine and store the compiled library files under /usr/include/boost.

After successfully building the b2 engine, there should be an executable file named b2 inside the Boost folder. This file needs to be run to begin building the Boost C++ libraries.

Using the Boost libraries

Here is an example that uses the Boost libraries :

This code uses the Boost.Filesystem library to get the root directory of the file system. It creates a boost::filesystem::path object representing the root directory (“/”), and then uses the root_directory() function to get the root directory and print it to the console.

Источник

Оцените статью
Adblock
detector