• Visual Studio 2019安装boost 1.7.0库


    小结

    在Visual Studio 2019使用了boost 1.7.0库,经过编译boost 1.7.0库,再添加配置到VS 2019工程中,进行了成功地测试。

    问题

    找不到boost的源文件

    如果没有安装boost库,会在Visual Studio 2019的工程编译过程中找不到相应的源文件。
    参见C++ problem: boost/asio.hpp non existing

    boost库的版本问题

    如果boost库的安装版本不对的话,会返回类似c2664 cannot convert executor to any_io_executor &的错误,参见Compiler Error C2664 , 这里我的情况是安装的boost库过高,安装了boost 1.7.9的库,原因不确定,但是安装低一点的版本boost 1.7.0库,这个问题就没有了。

    也有安装的版本过低的情况,也是有问题。返回类似LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc141-mt-gd-x32-1_66.lib'的问题。

    参见:
    fatal error LNK1104: cannot open file ‘libboost_system-vc110-mt-gd-1_51.lib’

    boost 1.7.0库的安装

    参见https://www.boost.org/users/history/version_1_70_0.html,下载boost 1.7.0库Windows Zip文件,解压缩。

    参见fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-gd-1_51.lib’的过程进行安装。

    首先需要执行以下VsDevCmd.bat指令,启动Visual Studio 2019 Developer Command Prompt v16.11.17

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools>VsDevCmd.bat
    **********************************************************************
    ** Visual Studio 2019 Developer Command Prompt v16.11.17
    ** Copyright (c) 2021 Microsoft Corporation
    **********************************************************************
    
    • 1
    • 2
    • 3
    • 4
    • 5

    否则会出现以下错误,
    'cl' is not recognized as an internal or external command, operable program or batch file
    和以下错误:
    fatal error C1034: ctype.h: no include path set

    参考Building Boost.Build engine ‘cl’ is not recognized as an internal or external command, operable program or batch file
    how to install boost correctly
    Error “fatal error C1034: windows.h: no include path set”

    再执行bootstrap.bat

    C:\boost_1_70_0>bootstrap.bat
    Building Boost.Build engine
    
    Generating Boost.Build configuration in project-config.jam for msvc...
    
    Bootstrapping is done. To build, run:
    
        .\b2
    
    To adjust configuration, edit 'project-config.jam'.
    Further information:
    
        - Command line help:
        .\b2 --help
    
        - Getting started guide:
        http://boost.org/more/getting_started/windows.html
    
        - Boost.Build documentation:
        http://www.boost.org/build/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    接着执行b2,生成library文件:

    C:\boost_1_70_0>.\b2
    Performing configuration checks
    
        - default address-model    : 32-bit
        - default architecture     : x86
    
    Building the Boost C++ Libraries.
    
    
        - C++11 mutex              : yes
        - Boost.Config Feature Check: cxx11_auto_declarations : yes
        - Boost.Config Feature Check: cxx11_constexpr : yes
        - Boost.Config Feature Check: cxx11_defaulted_functions : yes
        - Boost.Config Feature Check: cxx11_final : yes
        - Boost.Config Feature Check: cxx11_hdr_mutex : yes
        - Boost.Config Feature Check: cxx11_hdr_tuple : yes
        - Boost.Config Feature Check: cxx11_lambdas : yes
        - Boost.Config Feature Check: cxx11_noexcept : yes
        - Boost.Config Feature Check: cxx11_nullptr : yes
        - Boost.Config Feature Check: cxx11_rvalue_references : yes
        - Boost.Config Feature Check: cxx11_template_aliases : yes
        - Boost.Config Feature Check: cxx11_thread_local : yes
        - Boost.Config Feature Check: cxx11_variadic_templates : yes
        - has_icu builds           : no
    warning: Graph library does not contain MPI-based parallel components.
    note: to enable them, add "using mpi ;" to your user-config.jam
        - zlib                     : no
        - bzip2                    : no
        - lzma                     : no
        - zstd                     : no
        - iconv (libc)             : no
        - iconv (separate)         : no
        - icu                      : no
        - icu (lib64)              : no
        - native-atomic-int32-supported : yes
        - message-compiler         : yes
        - native-syslog-supported  : no
        - pthread-supports-robust-mutexes : no
        - compiler-supports-ssse3  : yes
        - compiler-supports-avx2   : yes
        - gcc visibility           : no
        - long double support      : yes
    warning: skipping optional Message Passing Interface (MPI) library.
    note: to enable MPI support, add "using mpi ;" to user-config.jam.
    note: to suppress this message, pass "--without-mpi" to bjam.
    note: otherwise, you can safely ignore this message.
        - libbacktrace builds      : no
        - addr2line builds         : no
        - WinDbg builds            : yes
        - WinDbgCached builds      : yes
        - BOOST_COMP_GNUC >= 4.3.0 : no
        - zlib                     : no  (cached)
        - bzip2                    : no  (cached)
        - lzma                     : no  (cached)
        - zstd                     : no  (cached)
        - C++11 mutex              : yes
        - Boost.Config Feature Check: cxx11_auto_declarations : yes
        - Boost.Config Feature Check: cxx11_constexpr : yes
        - Boost.Config Feature Check: cxx11_defaulted_functions : yes
        - Boost.Config Feature Check: cxx11_final : yes
        - Boost.Config Feature Check: cxx11_hdr_mutex : yes
        - Boost.Config Feature Check: cxx11_hdr_tuple : yes
        - Boost.Config Feature Check: cxx11_lambdas : yes
        - Boost.Config Feature Check: cxx11_noexcept : yes
        - Boost.Config Feature Check: cxx11_nullptr : yes
        - Boost.Config Feature Check: cxx11_rvalue_references : yes
        - Boost.Config Feature Check: cxx11_template_aliases : yes
        - Boost.Config Feature Check: cxx11_thread_local : yes
        - Boost.Config Feature Check: cxx11_variadic_templates : yes
        - has_icu builds           : no
        - zlib                     : no
        - bzip2                    : no
        - lzma                     : no
        - zstd                     : no
        - iconv (libc)             : no
        - iconv (separate)         : no
        - icu                      : no
        - icu (lib64)              : no
        - native-atomic-int32-supported : yes
        - message-compiler         : yes
        - native-syslog-supported  : no
        - pthread-supports-robust-mutexes : no
        - compiler-supports-ssse3  : yes
        - compiler-supports-avx2   : yes
        - gcc visibility           : no
        - long double support      : yes
        - libbacktrace builds      : no
        - addr2line builds         : no
        - WinDbg builds            : yes
        - WinDbgCached builds      : yes
        - BOOST_COMP_GNUC >= 4.3.0 : no
        - zlib                     : no  (cached)
        - bzip2                    : no  (cached)
        - lzma                     : no  (cached)
        - zstd                     : no  (cached)
    
    Component configuration:
    
        - atomic                   : building
        - chrono                   : building
        - container                : building
        - context                  : building
        - contract                 : building
        - coroutine                : building
        - date_time                : building
        - exception                : building
        - fiber                    : building
        - filesystem               : building
        - graph                    : building
        - graph_parallel           : building
        - headers                  : building
        - iostreams                : building
        - locale                   : building
        - log                      : building
        - math                     : building
        - mpi                      : building
        - program_options          : building
        - python                   : building
        - random                   : building
        - regex                    : building
        - serialization            : building
        - stacktrace               : building
        - system                   : building
        - test                     : building
        - thread                   : building
        - timer                    : building
        - type_erasure             : building
        - wave                     : building
    
    ...patience...
    ...patience...
    ...patience...
    ...patience...
    ...patience...
    ...found 26874 targets...
    ...updating 2407 targets...
    compile-c-c++ bin.v2\libs\python\build\msvc-14.2\debug\link-static\python-3.7\threading-multi\list.obj
    list.cpp
    ...
    ...
    ...
    中间过程省略,赶时间比较久,大概要半个小时。。。
    ...
    ...
    ...updated 2407 targets...
    
    
    The Boost C++ Libraries were successfully built!
    
    The following directory should be added to compiler include paths:
    
        C:\boost_1_70_0
    
    The following directory should be added to linker library paths:
    
        C:\boost_1_70_0\stage\lib
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158

    接着执行bjam.exe

    C:\boost_1_70_0>bjam.exe
    Performing configuration checks
    
        - default address-model    : 32-bit (cached)
        - default architecture     : x86 (cached)
    
    Building the Boost C++ Libraries.
    
    
        - C++11 mutex              : yes (cached)
        - Boost.Config Feature Check: cxx11_auto_declarations : yes (cached)
        - Boost.Config Feature Check: cxx11_constexpr : yes (cached)
        - Boost.Config Feature Check: cxx11_defaulted_functions : yes (cached)
        - Boost.Config Feature Check: cxx11_final : yes (cached)
        - Boost.Config Feature Check: cxx11_hdr_mutex : yes (cached)
        - Boost.Config Feature Check: cxx11_hdr_tuple : yes (cached)
        - Boost.Config Feature Check: cxx11_lambdas : yes (cached)
        - Boost.Config Feature Check: cxx11_noexcept : yes (cached)
        - Boost.Config Feature Check: cxx11_nullptr : yes (cached)
        - Boost.Config Feature Check: cxx11_rvalue_references : yes (cached)
        - Boost.Config Feature Check: cxx11_template_aliases : yes (cached)
        - Boost.Config Feature Check: cxx11_thread_local : yes (cached)
        - Boost.Config Feature Check: cxx11_variadic_templates : yes (cached)
        - has_icu builds           : no  (cached)
    warning: Graph library does not contain MPI-based parallel components.
    note: to enable them, add "using mpi ;" to your user-config.jam
        - zlib                     : no  (cached)
        - bzip2                    : no  (cached)
        - lzma                     : no  (cached)
        - zstd                     : no  (cached)
        - iconv (libc)             : no  (cached)
        - iconv (separate)         : no  (cached)
        - icu                      : no  (cached)
        - icu (lib64)              : no  (cached)
        - native-atomic-int32-supported : yes (cached)
        - message-compiler         : yes (cached)
        - native-syslog-supported  : no  (cached)
        - pthread-supports-robust-mutexes : no  (cached)
        - compiler-supports-ssse3  : yes (cached)
        - compiler-supports-avx2   : yes (cached)
        - gcc visibility           : no  (cached)
        - long double support      : yes (cached)
    warning: skipping optional Message Passing Interface (MPI) library.
    note: to enable MPI support, add "using mpi ;" to user-config.jam.
    note: to suppress this message, pass "--without-mpi" to bjam.
    note: otherwise, you can safely ignore this message.
        - libbacktrace builds      : no  (cached)
        - addr2line builds         : no  (cached)
        - WinDbg builds            : yes (cached)
        - WinDbgCached builds      : yes (cached)
        - BOOST_COMP_GNUC >= 4.3.0 : no  (cached)
        - zlib                     : no  (cached)
        - bzip2                    : no  (cached)
        - lzma                     : no  (cached)
        - zstd                     : no  (cached)
        - C++11 mutex              : yes (cached)
        - Boost.Config Feature Check: cxx11_auto_declarations : yes (cached)
        - Boost.Config Feature Check: cxx11_constexpr : yes (cached)
        - Boost.Config Feature Check: cxx11_defaulted_functions : yes (cached)
        - Boost.Config Feature Check: cxx11_final : yes (cached)
        - Boost.Config Feature Check: cxx11_hdr_mutex : yes (cached)
        - Boost.Config Feature Check: cxx11_hdr_tuple : yes (cached)
        - Boost.Config Feature Check: cxx11_lambdas : yes (cached)
        - Boost.Config Feature Check: cxx11_noexcept : yes (cached)
        - Boost.Config Feature Check: cxx11_nullptr : yes (cached)
        - Boost.Config Feature Check: cxx11_rvalue_references : yes (cached)
        - Boost.Config Feature Check: cxx11_template_aliases : yes (cached)
        - Boost.Config Feature Check: cxx11_thread_local : yes (cached)
        - Boost.Config Feature Check: cxx11_variadic_templates : yes (cached)
        - has_icu builds           : no  (cached)
        - zlib                     : no  (cached)
        - bzip2                    : no  (cached)
        - lzma                     : no  (cached)
        - zstd                     : no  (cached)
        - iconv (libc)             : no  (cached)
        - iconv (separate)         : no  (cached)
        - icu                      : no  (cached)
        - icu (lib64)              : no  (cached)
        - native-atomic-int32-supported : yes (cached)
        - message-compiler         : yes (cached)
        - native-syslog-supported  : no  (cached)
        - pthread-supports-robust-mutexes : no  (cached)
        - compiler-supports-ssse3  : yes (cached)
        - compiler-supports-avx2   : yes (cached)
        - gcc visibility           : no  (cached)
        - long double support      : yes (cached)
        - libbacktrace builds      : no  (cached)
        - addr2line builds         : no  (cached)
        - WinDbg builds            : yes (cached)
        - WinDbgCached builds      : yes (cached)
        - BOOST_COMP_GNUC >= 4.3.0 : no  (cached)
        - zlib                     : no  (cached)
        - bzip2                    : no  (cached)
        - lzma                     : no  (cached)
        - zstd                     : no  (cached)
    
    Component configuration:
    
        - atomic                   : building
        - chrono                   : building
        - container                : building
        - context                  : building
        - contract                 : building
        - coroutine                : building
        - date_time                : building
        - exception                : building
        - fiber                    : building
        - filesystem               : building
        - graph                    : building
        - graph_parallel           : building
        - headers                  : building
        - iostreams                : building
        - locale                   : building
        - log                      : building
        - math                     : building
        - mpi                      : building
        - program_options          : building
        - python                   : building
        - random                   : building
        - regex                    : building
        - serialization            : building
        - stacktrace               : building
        - system                   : building
        - test                     : building
        - thread                   : building
        - timer                    : building
        - type_erasure             : building
        - wave                     : building
    
    ...patience...
    ...patience...
    ...patience...
    ...patience...
    ...patience...
    ...patience...
    ...found 27172 targets...
    
    
    The Boost C++ Libraries were successfully built!
    
    The following directory should be added to compiler include paths:
    
        C:\boost_1_70_0
    
    The following directory should be added to linker library paths:
    
        C:\boost_1_70_0\stage\lib
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147

    需要添加C:\boost_1_70_0C:\boost_1_70_0\stage\lib到VS 2019工程文件中。

    添加boost 1.7.0库到VS 2019工程

    进行以下设置:

    • Configuration Properties > C/C++ > Precompiled Headers. 设置Not Using Precompiled Headers(不知道这个有没有用)

    • Set the “General > Platform Toolset” to Visual Studio 2019 (v142).

    • 设置"General > C Language Standard" to ISO C11 Standard (/std:c11) (不知道这个有没有用)

    • Include the path to the boost folder (e.g. C:\boost_1_70_0) and the path to the subfolder containing the binary files (e.g. C:\boost_1_70_0\stage\lib) in:“C\C++ > Additional Include Directory” and “Linker > Additional Library Directories”.

    编译问题

    参见Why does Visual Studio 2013 error on C4996?, 对于C4996的问题,进行以下设置解决:
    Apparently new projects enable “SDK check” by default now, which treats these warnings as errors. To disable it, go to project properties -> Configuration Properties -> C/C++ -> General -> SDL checks -> No.

    参考

    vs2015 安装boost库
    C++ problem: boost/asio.hpp non existing
    https://www.boost.org/users/history/version_1_70_0.html
    How to add boost library 1_65 or 1_64 to Visual Studio 2017 project?
    Compiler Error C2664
    Why does Visual Studio 2013 error on C4996?
    Having problems with Boost library and Visual Studio (C++)
    fatal error LNK1104: cannot open file ‘libboost_system-vc110-mt-gd-1_51.lib’
    Building Boost.Build engine ‘cl’ is not recognized as an internal or external command, operable program or batch file
    how to install boost correctly
    Error “fatal error C1034: windows.h: no include path set”

  • 相关阅读:
    基于Vue3水印组件封装:防篡改守护!
    Day 57 | 647. 回文子串 & 516. 最长回文子序列 & 动态规划总结
    30岁被裁,我想明白的几件事....
    kafka-console-producer.sh
    操作系统——内存管理
    40W-120W壁挂式SIP有源音柱
    【Linux系统管理】14 日志管理
    对 Vue 渐进式框架的理解
    链动2+1模式:让中小企业家轻松实现社交电商
    八皇后问题解法(Common Lisp实现)
  • 原文地址:https://blog.csdn.net/scruffybear/article/details/126167484