小結(jié)
在Visual Studio 2019使用了boost 1.7.0庫,經(jīng)過編譯boost 1.7.0庫,再添加配置到VS 2019工程中,進(jìn)行了成功地測(cè)試。
問題
找不到boost的源文件
如果沒有安裝boost庫,會(huì)在Visual Studio 2019的工程編譯過程中找不到相應(yīng)的源文件。
參見C++ problem: boost/asio.hpp non existing
boost庫的版本問題
如果boost庫的安裝版本不對(duì)的話,會(huì)返回類似c2664 cannot convert executor to any_io_executor &
的錯(cuò)誤,參見Compiler Error C2664 , 這里我的情況是安裝的boost庫過高,安裝了boost 1.7.9的庫,原因不確定,但是安裝低一點(diǎn)的版本boost 1.7.0庫,這個(gè)問題就沒有了。
也有安裝的版本過低的情況,也是有問題。返回類似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’的過程進(jìn)行安裝。
首先需要執(zhí)行以下VsDevCmd.bat指令,啟動(dòng)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
**********************************************************************
否則會(huì)出現(xiàn)以下錯(cuò)誤,'cl' is not recognized as an internal or external command, operable program or batch file
和以下錯(cuò)誤: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”
再執(zhí)行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/
接著執(zhí)行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
...
...
...
中間過程省略,趕時(shí)間比較久,大概要半個(gè)小時(shí)。。。
...
...
...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
接著執(zhí)行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工程
進(jìn)行以下設(shè)置:
-
Configuration Properties > C/C++ > Precompiled Headers. 設(shè)置
Not Using Precompiled Headers
(不知道這個(gè)有沒有用) -
Set the “General > Platform Toolset” to Visual Studio 2019 (v142).
-
設(shè)置"General > C Language Standard" to
ISO C11 Standard (/std:c11)
(不知道這個(gè)有沒有用) -
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?, 對(duì)于C4996的問題,進(jìn)行以下設(shè)置解決:
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.文章來源:http://www.zghlxwxcb.cn/news/detail-485819.html
參考
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”文章來源地址http://www.zghlxwxcb.cn/news/detail-485819.html
到了這里,關(guān)于Visual Studio 2019安裝boost 1.7.0庫的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!