How to install boost library in Linux system

  
                

A lot of people have problems installing the boost library on Linux. When using c++, they will be exposed to the boost library. The following small series will introduce you to the Linux system to install the boost library. Let's learn together. .

environment: Ubuntu 12.04 32bit, gcc 4.6.3

In fact, ubuntu, use the following command can be installed directly

sudo apt-get install libboost-dev

However, after this installation, there are a lot of errors when compiling the program, and they are all system file errors. I thought it was the version of the boost library. I changed the version several times and the same problem occurred. Later, I compiled a boost.1.42 myself. Then the program passed smoothly. Later I thought about the reason, probably because the boost installed by default from the above command did not enable mpi when compiling and packaging. And my program needs this feature. The following is a brief step of the installation (compiled with boost1.42 and boost1.50, the two installation methods are the same, the latter is an example):

1. Download the boost1.53 source file http://sourceforge. Net/projects/boost/files/latest/download? Source=dlp

2. After decompressing, go to the boost_1_53_0 directory and execute:. /bootstrap.sh

3. (Key) Modify the tools/build/v2/user-config.jam file, and add a line to the end "using mpi;" (note that there is a space after mpi. Then a semicolon)

4. Execute: . /b2

5. Execute: sudo. /b2 install

The above is the entire installation process, because there are more mentioned on the Internet, so it is omitted here. The key point is to mention the third step, remember to remember. However, if your program does not require the mpi feature, then it does not matter. Apply the default settings. Moreover, the fourth step, the execution can be in the back of the home prefix parameters, if not added, the default header file is installed in the /usr/local/include/boost directory. The library files are in the /usr/local/lib/directory. No modification is required by default.

If you can't load a library file after running the program, you can use the /vr/local/lib all the library files mv to the /usr/lib directory.

The above is the introduction of the Linux system to install the boost library. This article also explains the problems encountered during the installation of the boost library. If you encounter these problems in the installation of the domestic, you can try the method described in this article. Process it.

Copyright © Windows knowledge All Rights Reserved