Cómo instalar Boost en Ubuntu


Estoy en Ubuntu, y quiero instalar Boost. Lo intenté con

sudo apt-get install boost

Pero no había tal paquete. ¿Cuál es la mejor manera de instalar Boost en Ubuntu?

 357
Author: Peter Mortensen, 2012-09-25

6 answers

Puede usar el comando apt-get (requiere sudo)

sudo apt-get install libboost-all-dev

O puedes llamar

aptitude search boost

Encuentre los paquetes que necesita e instálelos usando el comando apt-get.

 623
Author: Anton Guryanov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-09-25 07:57:27

Obtenga la versión de Boost que necesita. Esto es para 1.55, pero no dude en cambiar o descargar manualmente usted mismo:

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/

Obtenga las bibliotecas requeridas, las principales son icu para boost::regex soporte:

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

Configuración de bootstrap de Boost:

./bootstrap.sh --prefix=/usr/

Luego construirlo con:

./b2

Y finalmente instalarlo:

sudo ./b2 install
 125
Author: user3715812,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-30 18:09:55

Instalación de Boost en Ubuntu con un ejemplo de uso boost::array:

Instalar libboost-all-dev y aptitude:

sudo apt-get install libboost-all-dev

sudo apt-get install aptitude

aptitude search boost

Luego pega esto en un archivo C++ llamado main.cpp:

#include <iostream>
#include <boost/array.hpp>

using namespace std;
int main(){
  boost::array<int, 4> arr = {{1,2,3,4}};
  cout << "hi" << arr[0];
  return 0;
}

Compilar así:

g++ -o s main.cpp

Ejecútalo así:

./s

Impresiones del programa:

hi1
 64
Author: Eric Leschinski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-03 14:44:24

Obtenga la versión de Boost que necesita. Esto es para 1.55, pero no dude en cambiar o descargar manualmente usted mismo:

wget -O boost_1_55_0.tar.gz http://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/

Obtenga las bibliotecas requeridas, las principales son icu para boost:: regex support:

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

Configuración de bootstrap de Boost:

./bootstrap.sh --prefix=/usr/local

Si queremos MPI entonces necesitamos establecer la bandera en el user-config.jam file:

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

Encuentre el número máximo de núcleos físicos:

n=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`

Instalar boost en paralelo:

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

Asume que usted tiene /usr/local/lib ya está configurado. si no, puede agregarlo a su RUTA de la BIBLIOTECA LD :

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

Restablecer el ldconfig:

sudo ldconfig
 10
Author: Ahmed Elcheikh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-21 22:13:05

Una actualización para la aplicación Ubuntu de Windows 10 a través del Subsistema (también funciona en Ubuntu estándar):

Es posible que tenga problemas para encontrar el paquete. ¡Si lo haces, no temas! PPA está aquí!

sudo add-apt-repository ppa:boost-latest/ppa
sudo apt-get update

Luego ejecute:

sudo apt-get install libboost-all-dev
 4
Author: x4g0tt3nSou1x,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-03 14:46:44

En realidad no necesitas "instalar" o "compilar" nada antes de usar Boost en tu proyecto. Simplemente puede descargar y extraer la biblioteca Boost a cualquier ubicación de su máquina, que generalmente es como /usr/local/.

Cuando compile su código, simplemente puede indicar al compilador dónde encontrar las bibliotecas mediante -I. Por ejemplo, g++ -I /usr/local/boost_1_59_0 xxx.hpp.

 0
Author: jimmy.zhao,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-03 14:45:37