Compile and install boost (on Windows and Solaris)

Source: Internet
Author: User

David Note: This is my note when I first studied boost. I recently saw someone asking on the Forum, So I posted it for sharing. In fact, I personally think that boost is not suitable for application development at present. After all, the boost library is too large (of course, you can only use a part, but the maintainability of the program is always a problem ), unless you want to explore the magical world of generic programming, the cutting-edge meta programming in C ++ research. It is strongly recommended that boost researchers study a much smaller template library Loki before studying boost. Many boost technologies that you cannot understand are widely used in the Loki library, the author of this library wrote modern c ++ design to explain the implementation of this library. In addition, if you want to study boost, do not compile all the libraries at the beginning, such as Python, thread, and test, because after several hours of compilation, you may find that, you can't use these libraries at all, or you are not interested in it at all. It is not too late to compile the Libraries after you have fully understood boost.

Note:
1. Make sure that the appropriate compiler has been installed on your OS. In the following Windows environment, use Windows 2000 + vc6 as an example, and in UNIX environment, use Solaris 9 + GCC 3.4.2 as an example;
2. The following $ boostdir indicates the boost storage directory. Modify it based on your actual situation.

O. Download + unpack (omitted)

1. Compile jam
1. Windows
Run build. bat under $ boostdir/tools/build/jam_src to compile jam. The compilation results will be stored under $ boostdir/tools/build/jam_src/bin. ntx86. If you encounter problems when executing the batch processing program, if the report cannot find the compiler-related program, execute
X:/program files/Microsoft Visual Studio/vc98/bin/vcvars32.bat
To create the basic environment variables of VC.
2. Solaris 9
Run./build. Sh under $ boostdir/tools/build/jam_src to compile jam. The compilation results will be stored in $ boostdir/tools/build/jam_src/bin. solarisx86.

Ii. Set Environment Variables
(Note: This step can be omitted. You can directly input it to the command line through-s in (3), but the setting can make the command line clearer and simpler .)
1. Windows
Right-click my computer and choose Properties> advanced> environment variable> User variable or system variable:
Add the bjam directory at the end of path, for example:
$ Boostdir/tools/build/jam_src/bin. ntx86
Create an environment variable msvcdir and enter the VC installation directory in the variable value column, for example:
X:/program files/Microsoft Visual Studio/vc98
Create an environment variable:
Python_root = x:/program files/python2.3.4
Python_version = 2.3
2. Solaris 9
Add the compiled jam directory after path in. profile.
And add
Python_version = 2.3
Export python_version
Note: you do not need to set python_root. Jam will automatically process the configuration under Solaris.

Iii. Compilation
1. Windows
Run the following command under $ boostdir:
Jam-sboost_root =.-stools = msvc "-sbuild = debug release <runtime-link> static/dynamic"
The preceding commands are explained as follows:
-S is set, which is used to set environment variables;
Boost_root boost storage directory
Tools toolset you selected, such as GCC, msvc (vc6), and vc7.1. In addition, there are gcc-stlport, msvc-stlport, and vc7.1-stlport, indicating that stlport is used at the same time. You can go to $ boostdir/tools/build/V1 to check the specific toolset supported.
Build compilation type. The above options indicate that the debug and release versions (four versions) that support static and dynamic links are compiled ).

The compiled lib and DLL files will be copied to the $ boostdir/bin/Boost/libs directory. However, these lib and DLL files are scattered in different directories for ease of use, you can find * in the preceding directory *. lib and *. DLL to find out these files, and then copy them all to the lib directory of VC and the System32 directory of windows, you can also create a directory dedicated to storing boost lib files, and then
Select Tools> Options> directories> library files, and add the preceding directory path to the environment settings of VC.
2. Solaris 9
Run the following command under $ boostdir:
Jam-sboost_root =.-stools = GCC "-sbuild = debug release <runtime-link> static/dynamic"
However, the following command is recommended:
Jam-sboost_root =.-stools = GCC "-sbuild = release <runtime-link> dynamic <optimization> speed"
This can greatly speed up compilation. At the same time, I personally think that it is best to use dynamic links to reduce the size of the target program, just like libstdc ++, I have never seen anyone go to the static link libstdc ++. a, although the static library is provided in the system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.