0
点赞
收藏
分享

微信扫一扫

Visual Studio 2019安装boost 1.7.0库


文章目录

  • ​​小结​​
  • ​​问题​​
  • ​​找不到boost的源文件​​
  • ​​boost库的版本问题​​
  • ​​boost 1.7.0库的安装​​
  • ​​添加boost 1.7.0库到VS 2019工程​​
  • ​​编译问题​​
  • ​​参考​​

小结

在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
**********************************************************************

否则会出现以下错误,
​​​'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/

接着执行​​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

接着执行​​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

需要添加​​C:\boost_1_70_0​​​和​​C:\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.

举报

相关推荐

0 条评论