阅读量:2
目录
1 Boost概述
Boost提供免费的同行评审的可移植C++源库。
我们强调与C++标准库配合良好的库。Boost库旨在广泛使用,并可在广泛的应用程序中使用。Boost许可证鼓励所有用户以最小的限制使用Boost库。
我们的目标是建立“现有实践”并提供参考实现,以便Boost库适合最终的标准化。从库技术报告(TR1)中包含的十个Boost库开始,再到自2011年以来ISO C++标准的每次发布,C++标准委员会一直将Boost作为添加标准C++库的宝贵来源。
2 Linux编译
2.1 解压
$ tar zxf boost_1_85_0.tar.gz $ cd boost_1_85_0/ $ ll 总用量 132 drwxr-xr-x 8 james james 4096 4月 12 03:23 ./ drwxrwxr-x 17 james james 4096 7月 15 09:51 ../ drwxr-xr-x 143 james james 12288 4月 12 03:23 boost/ -rw-r--r-- 1 james james 851 4月 12 02:47 boost-build.jam -rw-r--r-- 1 james james 20245 4月 12 02:47 boostcpp.jam -rw-r--r-- 1 james james 989 4月 12 02:47 boost.css -rw-r--r-- 1 james james 6308 4月 12 02:47 boost.png -rw-r--r-- 1 james james 2486 4月 12 02:47 bootstrap.bat -rwxr-xr-x 1 james james 10811 4月 12 02:47 bootstrap.sh* drwxr-xr-x 8 james james 4096 4月 12 03:23 doc/ -rw-r--r-- 1 james james 769 4月 12 02:47 index.htm -rw-r--r-- 1 james james 5418 4月 12 03:23 index.html -rw-r--r-- 1 james james 291 4月 12 02:47 INSTALL -rw-r--r-- 1 james james 12230 4月 12 02:47 Jamroot drwxr-xr-x 152 james james 4096 4月 12 03:23 libs/ -rw-r--r-- 1 james james 1338 4月 12 02:47 LICENSE_1_0.txt drwxr-xr-x 4 james james 4096 4月 12 02:48 more/ -rw-r--r-- 1 james james 541 4月 12 02:47 README.md -rw-r--r-- 1 james james 2608 4月 12 02:47 rst.css drwxr-xr-x 2 james james 4096 4月 12 02:47 status/ drwxr-xr-x 14 james james 4096 4月 12 02:47 tools/
2.2 编译B2
B2是Boost软件使用的编译系统,要编译bootst需要编译B2编译系统。
$ ./bootstrap.sh Building B2 engine.. ### ### ### Using 'gcc' toolset. ### ### g++ (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ### ### > g++ -x c++ -std=c++11 -pthread -O2 -s -DNDEBUG bindjam.cpp builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filent.cpp filesys.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp tasks.cpp timestamp.cpp value.cpp variable.cpp w32_getreg.cpp mod_jam_builtin.cpp mod_jam_class.cpp mod_jam_errors.cpp mod_jam_modules.cpp mod_order.cpp mod_path.cpp mod_property_set.cpp mod_regex.cpp mod_sequence.cpp mod_set.cpp mod_string.cpp mod_summary.cpp mod_sysinfo.cpp mod_version.cpp -o b2 tools/build/src/engine/b2 Detecting Python version... 2.7 Detecting Python root... /usr Unicode/ICU support for Boost.Regex?... not found. Backing up existing B2 configuration in project-config.jam.1 Generating B2 configuration in project-config.jam for gcc... Bootstrapping is done. To build, run: ./b2 To generate header files, run: ./b2 headers The configuration generated uses gcc to build by default. If that is unintended either use the --with-toolset option or adjust configuration, by editing 'project-config.jam'. Further information: - Command line help: ./b2 --help - Getting started guide: http://www.boost.org/more/getting_started/unix-variants.html - B2 documentation: http://www.boost.org/build/
编译结果:
$ ll b2 -rwxrwxr-x 1 james james 544848 7月 15 09:57 b2*
b2这个可执行程序就是b2编译系统系统。
2.3 编译
$ ./b2 --build-type=minimal $ cd bin.v2/ $ find -name *.a ./libs/type_erasure/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_type_erasure.a ./libs/atomic/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_atomic.a ./libs/graph/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_graph.a ./libs/program_options/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_program_options.a ./libs/coroutine/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_coroutine.a ./libs/filesystem/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_filesystem.a ./libs/random/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_random.a ./libs/json/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_json.a ./libs/locale/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_locale.a ./libs/timer/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_timer.a ./libs/fiber/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_fiber.a ./libs/math/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_math_tr1f.a ./libs/math/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_math_c99.a ./libs/math/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_math_c99l.a ./libs/math/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_math_tr1l.a ./libs/math/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_math_c99f.a ./libs/math/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_math_tr1.a ./libs/serialization/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_serialization.a ./libs/serialization/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_wserialization.a ./libs/thread/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_thread.a ./libs/log/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_log_setup.a ./libs/log/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_log.a ./libs/stacktrace/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_stacktrace_from_exception.a ./libs/stacktrace/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_stacktrace_basic.a ./libs/stacktrace/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_stacktrace_addr2line.a ./libs/stacktrace/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_stacktrace_backtrace.a ./libs/stacktrace/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_stacktrace_noop.a ./libs/exception/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_exception.a ./libs/system/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_system.a ./libs/nowide/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_nowide.a ./libs/regex/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_regex.a ./libs/charconv/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_charconv.a ./libs/contract/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_contract.a ./libs/test/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_test_exec_monitor.a ./libs/test/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_prg_exec_monitor.a ./libs/test/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_unit_test_framework.a ./libs/context/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_context.a ./libs/iostreams/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_iostreams.a ./libs/date_time/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_date_time.a ./libs/wave/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_wave.a ./libs/chrono/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_chrono.a ./libs/container/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_container.a ./libs/url/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_url.a $ find -name *.s* ./libs/type_erasure/build/gcc-8/release/threading-multi/visibility-hidden/libboost_type_erasure.so.1.85.0 ./libs/atomic/build/gcc-8/release/threading-multi/visibility-hidden/libboost_atomic.so.1.85.0 ./libs/graph/build/gcc-8/release/threading-multi/visibility-hidden/libboost_graph.so.1.85.0 ./libs/program_options/build/gcc-8/release/threading-multi/visibility-hidden/libboost_program_options.so.1.85.0 ./libs/coroutine/build/gcc-8/release/threading-multi/visibility-hidden/libboost_coroutine.so.1.85.0 ./libs/filesystem/build/gcc-8/release/threading-multi/visibility-hidden/libboost_filesystem.so.1.85.0 ./libs/filesystem/config/gcc-8/release/threading-multi/visibility-hidden/libhas_linkflag_no_undefined.so.1.85.0 ./libs/random/build/gcc-8/release/threading-multi/visibility-hidden/libboost_random.so.1.85.0 ./libs/json/build/gcc-8/release/threading-multi/visibility-hidden/libboost_json.so.1.85.0 ./libs/locale/build/gcc-8/release/threading-multi/visibility-hidden/libboost_locale.so.1.85.0 ./libs/timer/build/gcc-8/release/threading-multi/visibility-hidden/libboost_timer.so.1.85.0 ./libs/fiber/build/gcc-8/release/threading-multi/visibility-hidden/libboost_fiber.so.1.85.0 ./libs/math/build/gcc-8/release/threading-multi/visibility-hidden/libboost_math_c99f.so.1.85.0 ./libs/math/build/gcc-8/release/threading-multi/visibility-hidden/libboost_math_tr1.so.1.85.0 ./libs/math/build/gcc-8/release/threading-multi/visibility-hidden/libboost_math_tr1l.so.1.85.0 ./libs/math/build/gcc-8/release/threading-multi/visibility-hidden/libboost_math_c99l.so.1.85.0 ./libs/math/build/gcc-8/release/threading-multi/visibility-hidden/libboost_math_tr1f.so.1.85.0 ./libs/math/build/gcc-8/release/threading-multi/visibility-hidden/libboost_math_c99.so.1.85.0 ./libs/serialization/build/gcc-8/release/threading-multi/visibility-hidden/libboost_serialization.so.1.85.0 ./libs/serialization/build/gcc-8/release/threading-multi/visibility-hidden/libboost_wserialization.so.1.85.0 ./libs/thread/build/gcc-8/release/threading-multi/visibility-hidden/libboost_thread.so.1.85.0 ./libs/log/build/gcc-8/release/threading-multi/visibility-hidden/libboost_log_setup.so.1.85.0 ./libs/log/build/gcc-8/release/threading-multi/visibility-hidden/libboost_log.so.1.85.0 ./libs/stacktrace/build/gcc-8/release/threading-multi/visibility-hidden/libboost_stacktrace_noop.so.1.85.0 ./libs/stacktrace/build/gcc-8/release/threading-multi/visibility-hidden/libboost_stacktrace_backtrace.so.1.85.0 ./libs/stacktrace/build/gcc-8/release/threading-multi/visibility-hidden/libboost_stacktrace_from_exception.so.1.85.0 ./libs/stacktrace/build/gcc-8/release/threading-multi/visibility-hidden/libboost_stacktrace_basic.so.1.85.0 ./libs/stacktrace/build/gcc-8/release/threading-multi/visibility-hidden/libboost_stacktrace_addr2line.so.1.85.0 ./libs/system/build/gcc-8/release/threading-multi/visibility-hidden/libboost_system.so.1.85.0 ./libs/nowide/build/gcc-8/release/threading-multi/visibility-hidden/libboost_nowide.so.1.85.0 ./libs/regex/build/gcc-8/release/threading-multi/visibility-hidden/libboost_regex.so.1.85.0 ./libs/charconv/build/gcc-8/release/threading-multi/visibility-hidden/libboost_charconv.so.1.85.0 ./libs/contract/build/gcc-8/release/threading-multi/visibility-hidden/libboost_contract.so.1.85.0 ./libs/test/build/gcc-8/release/threading-multi/visibility-hidden/libboost_prg_exec_monitor.so.1.85.0 ./libs/test/build/gcc-8/release/threading-multi/visibility-hidden/libboost_unit_test_framework.so.1.85.0 ./libs/context/build/gcc-8/release/threading-multi/visibility-hidden/libboost_context.so.1.85.0 ./libs/iostreams/build/gcc-8/release/threading-multi/visibility-hidden/libboost_iostreams.so.1.85.0 ./libs/date_time/build/gcc-8/release/threading-multi/visibility-hidden/libboost_date_time.so.1.85.0 ./libs/wave/build/gcc-8/release/threading-multi/visibility-hidden/libboost_wave.so.1.85.0 ./libs/chrono/build/gcc-8/release/threading-multi/visibility-hidden/libboost_chrono.so.1.85.0 ./libs/container/build/gcc-8/release/threading-multi/visibility-hidden/libboost_container.so.1.85.0 ./libs/url/build/gcc-8/release/threading-multi/visibility-hidden/libboost_url.so.1.85.0
说明:
- boost编译生成release版本的静态库和动态库
- 如果需要编译debug版本静态库和动态库,增加编译参数–build-type=complete
2.3 安装
$ ./b2 install --prefix=/home/xxx/bootst1.85 $ cd /home/xxx/bootst1.85 $ ll 总用量 24 drwxrwxr-x 4 james james 4096 7月 15 10:14 ./ drwxr-xr-x 42 james james 4096 7月 15 10:14 ../ drwxrwxr-x 3 james james 4096 7月 15 10:14 include/ drwxrwxr-x 3 james james 12288 7月 15 10:14 lib/ $ ls lib cmake libboost_graph.a libboost_math_tr1l.so libboost_stacktrace_from_exception.so libboost_atomic.a libboost_graph.so libboost_math_tr1l.so.1.85.0 libboost_stacktrace_from_exception.so.1.85.0 libboost_atomic.so libboost_graph.so.1.85.0 libboost_math_tr1.so libboost_stacktrace_noop.a libboost_atomic.so.1.85.0 libboost_iostreams.a libboost_math_tr1.so.1.85.0 libboost_stacktrace_noop.so libboost_charconv.a libboost_iostreams.so libboost_nowide.a libboost_stacktrace_noop.so.1.85.0 libboost_charconv.so libboost_iostreams.so.1.85.0 libboost_nowide.so libboost_system.a libboost_charconv.so.1.85.0 libboost_json.a libboost_nowide.so.1.85.0 libboost_system.so libboost_chrono.a libboost_json.so libboost_prg_exec_monitor.a libboost_system.so.1.85.0 libboost_chrono.so libboost_json.so.1.85.0 libboost_prg_exec_monitor.so libboost_test_exec_monitor.a libboost_chrono.so.1.85.0 libboost_locale.a libboost_prg_exec_monitor.so.1.85.0 libboost_thread.a libboost_container.a libboost_locale.so libboost_program_options.a libboost_thread.so libboost_container.so libboost_locale.so.1.85.0 libboost_program_options.so libboost_thread.so.1.85.0 libboost_container.so.1.85.0 libboost_log.a libboost_program_options.so.1.85.0 libboost_timer.a libboost_context.a libboost_log_setup.a libboost_random.a libboost_timer.so libboost_context.so libboost_log_setup.so libboost_random.so libboost_timer.so.1.85.0 libboost_context.so.1.85.0 libboost_log_setup.so.1.85.0 libboost_random.so.1.85.0 libboost_type_erasure.a libboost_contract.a libboost_log.so libboost_regex.a libboost_type_erasure.so libboost_contract.so libboost_log.so.1.85.0 libboost_regex.so libboost_type_erasure.so.1.85.0 libboost_contract.so.1.85.0 libboost_math_c99.a libboost_regex.so.1.85.0 libboost_unit_test_framework.a libboost_coroutine.a libboost_math_c99f.a libboost_serialization.a libboost_unit_test_framework.so libboost_coroutine.so libboost_math_c99f.so libboost_serialization.so libboost_unit_test_framework.so.1.85.0 libboost_coroutine.so.1.85.0 libboost_math_c99f.so.1.85.0 libboost_serialization.so.1.85.0 libboost_url.a libboost_date_time.a libboost_math_c99l.a libboost_stacktrace_addr2line.a libboost_url.so libboost_date_time.so libboost_math_c99l.so libboost_stacktrace_addr2line.so libboost_url.so.1.85.0 libboost_date_time.so.1.85.0 libboost_math_c99l.so.1.85.0 libboost_stacktrace_addr2line.so.1.85.0 libboost_wave.a libboost_exception.a libboost_math_c99.so libboost_stacktrace_backtrace.a libboost_wave.so libboost_fiber.a libboost_math_c99.so.1.85.0 libboost_stacktrace_backtrace.so libboost_wave.so.1.85.0 libboost_fiber.so libboost_math_tr1.a libboost_stacktrace_backtrace.so.1.85.0 libboost_wserialization.a libboost_fiber.so.1.85.0 libboost_math_tr1f.a libboost_stacktrace_basic.a libboost_wserialization.so libboost_filesystem.a libboost_math_tr1f.so libboost_stacktrace_basic.so libboost_wserialization.so.1.85.0 libboost_filesystem.so libboost_math_tr1f.so.1.85.0 libboost_stacktrace_basic.so.1.85.0 libboost_filesystem.so.1.85.0 libboost_math_tr1l.a libboost_stacktrace_from_exception.a