Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile boost in Linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how the Linux system compiles boost. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Boost library is a portable, source code C++ library, as the backup of the standard library, is one of the development engines of C++ standardization process.

About Boost: boost library is a portable, source code C++ library, as a backup to the standard library, C++ standardization process is one of the development engines.

The boost library is initiated by members of the working Group of the C++ Standards Committee, and some of its content is expected to become the next generation of C++ standard library. It has a great influence in the C++ community, and it is a real "quasi" standard library.

Because of its emphasis on cross-platform, boost's emphasis on C++ has nothing to do with the writing platform.

Specific method of compiling Boost in Linux system: instead of using make, which has become a recognized standard, Boost is compiled using a tool bjam (boost jam) * *, which is specially developed for Boost. 1. / bootstrap.sh generates bjam2. . / bjam-with-filesystem-create command executed by layout=tagged variant=release link=static threading=single stage (not all compiled)\ 3. / bjam install installation

Two compressed versions of the boost library are officially available under Linux: boost_1_43_0.tar.bz2boost_1_43_0.tar.gz.

Find the direct download address of one of the Unix/Linux packages and enter the following command

Sudo wget http://downloads.sourceforge.net/project/boost/boost/1.43.0/boost_1_43_0.tar.gz?use_mirror=cdnetworks-kr-1

Decompress tar-zxvf boost_1.43.0.tar.gz

Enter the decompressed directory cd boost_1_43_0

The compilation installation uses the following command to create boost's own compilation tool, bjam (designed to ensure that Boost can be compiled with bjam on any platform), similar to GNU Make. . / bootstrap.sh-prefix=/home/usrname/boost_1_43_0/boost_install

Boost will be installed in the / boost_install directory, and unknown prefix will be installed under / usr/local/include and / usr/local/lib by default.

It is recommended that you first check the help documentation to learn about some default options, and the command is. / bjam-help

The format of the .bjam command is: bjam [options] [properties] [targets]

For the description of common options (Options) and attributes (Properties), the keyword with the-prefix is option, and the one that does not have is property.

-show-libraries displays a list of libraries that need to be compiled before they can be used

-build-type=minimal | complete-build-type=minimal is the default. In this case, only multithreaded static libraries and dynamic libraries of the release version of the dynamic link C runtime (C++ standard library) are compiled under Linux. -build-type=complete, multiple variants to be compiled under Unix/linux (debug or release, multithreaded or single-threaded, static or dynamic libraries, static or dynamically linked C runtime / C++ standard library). Full compilation is not recommended, time-consuming and space-consuming, and on-demand compilation is advocated.

-layout=versioned | tagged | system determines the generation strategy of the library name to be compiled and the address directory name of the header file. Default Windows-layout=versioned,Linux-layout=system. When compiling multiple versions at the same time, it is best to set-layout=versioned or-layout=tagged, otherwise the compilation will probably fail, because if some versions are compiled at the same time, if you do not specify a naming policy, it may cause naming conflicts when outputting to the specified directory. Note: when-build-type=complete, you do not need to set this property. However, when specifying attributes such as variant=debug,release, make sure-layout=versioned or-layout=tagged.

-build-dir=DIR specifies the directory where the intermediate files, target files and other files generated during compilation are stored. / bin.v2 is the default.

-with- creates and installs specified libraries-without- does not create and install specified libraries, but creates all libraries by default

Installation: the keywords install or stage./bjam installinstall will install the header files and library files to the corresponding specified directory, the header files will be installed under / usr/local/include, and the library files will be installed under / usr/local/lib. For the specified installation directory, see. / bjam-help. . / bjam stagestage can only be said to collect the generated library files into a directory, usually under. / stage by default.

Note: it seems that install and stage cannot be used at the same time, they will get stuck in the middle. If install or stage is not specified during compilation, the resulting target library file exists only in the directory referred to by-build-dir, default to. / bin.v2. With this in mind, the stage keyword is recommended if you do not need to install header and library files.

Here are the properties: toolset=toolset specifies the compiler, which is automatically detected by default, and can be used when multiple compilers are installed. Variant=debug | release specifies that the debug or release version is compiled. Link=static | shared specifies the creation of static or dynamic libraries runtime-link=static | shared specifies whether the created libraries are statically linked or dynamically linked to the C runtime (or C++ standard library). This option depends on the type of-link. Different compilers allow different linking strategies. For example, under GCC, static linking to the C runtime (or C++ standard library) is not allowed when generating dynamic libraries (- link=shared). Threading=single | multi specifies to create a multithreaded or single-threaded version library.

Property can be set at the same time in the following two ways. In order to avoid name conflicts, it is recommended to use the format of propery=value:. / bjam variant=debug,release stage or. / bjam variant=debug variant=release.

* the last creation command executed: *. / bjam-with-filesystem-layout=tagged variant=release link=static threading=single stage

* install *

#. / bjam install

Install the generated libraries to the / urs/local/lib directory by default.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The above is how the Linux system compiles boost. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report