cmake Could NOT find Boost (missing: xxx的问题解决
在window上编译solidity的时候,先进行sln工程的生成,根据官方文档执行cmake即可:
cmake -G "Visual Studio 16 2019" ..
或者在没有BOOST_ROOT环境变量的情况下额外指定boost路径。我是有BOOST_ROOT环境变量的,所以未指定,但是题目中的问题与此无关。
直接执行上面命令报错了。。。:
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Boost (missing: filesystem unit_test_framework
program_options system) (found suitable version "1.70.0", minimum required
is "1.65.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2145 (find_package_handle_standard_args)
cmake/EthDependencies.cmake:34 (find_package)
CMakeLists.txt:42 (include)
从报错信息中可以看到cmake其实已经找到boost了,版本为1.70.0,这是正确的。但是为什么找不到那几个库呢?
我上网查了加上【BOOST_LIBRARYDIR】选项,可以指定库的路径,但是不知道具体指定到那个层级,我的实际存储在【boost_1_70_0\stage64\lib】下,但是我后来在【BOOST_LIBRARYDIR】中只指定到了stage64。结果还是报一样的错误,其实这时候我没有意识到是路径还需要再深一层,我以为这个选项不管用。。。
也正是因为这个,让我遇到了一个更厉害的选项:【-DBoost_DEBUG=ON】这是用来在使用cmake查找boost的时候打印查找过程信息的,加了这个选项后:
cmake -G "Visual Studio 16 2019" .. -DBoost_DEBUG=ON
整个过程清晰明了了,会输出以下信息(略长,就是cmake能获取到的当前环境中boost的基本信息,及一些查找路径)
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19043.
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1466 ] _boost_TEST_VERSIONS = "1.72.0;1.72;1.71.0;1.71;1.70.0;1.70;1.69.0;1.69;1.68.0;1.68;1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1467 ] Boost_USE_MULTITHREADED = "ON"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1468 ] Boost_USE_STATIC_LIBS = "ON"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1469 ] Boost_USE_STATIC_RUNTIME = "ON"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1470 ] Boost_ADDITIONAL_VERSIONS = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1471 ] Boost_NO_SYSTEM_PATHS = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1503 ] BOOST_ROOT = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1504 ] ENV{BOOST_ROOT} = "D:\lib\boost_1_70_0"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1505 ] BOOST_INCLUDEDIR = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1506 ] ENV{BOOST_INCLUDEDIR} = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1507 ] BOOST_LIBRARYDIR = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1508 ] ENV{BOOST_LIBRARYDIR} = <unset>
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1596 ] location of version.hpp: D:/lib/boost_1_70_0/boost/version.hpp
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1636 ] Boost_VERSION = "107000"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1637 ] Boost_VERSION_STRING = "1.70.0"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1638 ] Boost_VERSION_MACRO = "107000"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1639 ] Boost_VERSION_MAJOR = "1"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1640 ] Boost_VERSION_MINOR = "70"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1641 ] Boost_VERSION_PATCH = "0"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1642 ] Boost_VERSION_COUNT = "3"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1659 ] Boost_LIB_PREFIX = "lib"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1660 ] Boost_NAMESPACE = "boost"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:793 ] _boost_COMPILER = "-vc142;-vc141;-vc140" (guessed)
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1696 ] _boost_MULTITHREADED = "-mt"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1773 ] _boost_ARCHITECTURE_TAG = "-x64" (detected)
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1777 ] _boost_RELEASE_ABI_TAG = "-s"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1778 ] _boost_DEBUG_ABI_TAG = "-sgd"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1838 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = "D:/lib/boost_1_70_0/lib;D:/lib/boost_1_70_0/stage/lib;D:/lib/boost_1_70_0/lib64-msvc-14.2;D:/lib/boost_1_70_0/lib64-msvc-14.1;D:/lib/boost_1_70_0/lib64-msvc-14.0;D:/lib/boost_1_70_0/lib;D:/lib/boost_1_70_0/../lib;D:/lib/boost_1_70_0/stage/lib;D:/lib/boost_1_70_0/../lib64-msvc-14.2;D:/lib/boost_1_70_0/../lib64-msvc-14.1;D:/lib/boost_1_70_0/../lib64-msvc-14.0;D:/lib/boost_1_70_0/lib64-msvc-14.2;D:/lib/boost_1_70_0/lib64-msvc-14.1;D:/lib/boost_1_70_0/lib64-msvc-14.0;C:/local/boost_1_72_0/lib64-msvc-14.2;C:/local/boost_1_72_0/lib64-msvc-14.1;C:/local/boost_1_72_0/lib64-msvc-14.0;C:/local/boost_1_72/lib64-msvc-14.2;C:/local/boost_1_72/lib64-msvc-14.1;C:/local/boost_1_72/lib64-msvc-14.0;C:/local/boost_1_71_0/lib64-msvc-14.2;C:/local/boost_1_71_0/lib64-msvc-14.1;C:/local/boost_1_71_0/lib64-msvc-14.0;C:/local/boost_1_71/lib64-msvc-14.2;C:/local/boost_1_71/lib64-msvc-14.1;C:/local/boost_1_71/lib64-msvc-14.0;C:/local/boost_1_70_0/lib64-msvc-14.2;C:/local/boost_1_70_0/lib64-msvc-14.1;C:/local/boost_1_70_0/lib64-msvc-14.0;C:/local/boost_1_70/lib64-msvc-14.2;C:/local/boost_1_70/lib64-msvc-14.1;C:/local/boost_1_70/lib64-msvc-14.0;C:/local/boost_1_69_0/lib64-msvc-14.2;C:/local/boost_1_69_0/lib64-msvc-14.1;C:/local/boost_1_69_0/lib64-msvc-14.0;C:/local/boost_1_69/lib64-msvc-14.2;C:/local/boost_1_69/lib64-msvc-14.1;C:/local/boost_1_69/lib64-msvc-14.0;C:/local/boost_1_68_0/lib64-msvc-14.2;C:/local/boost_1_68_0/lib64-msvc-14.1;C:/local/boost_1_68_0/lib64-msvc-14.0;C:/local/boost_1_68/lib64-msvc-14.2;C:/local/boost_1_68/lib64-msvc-14.1;C:/local/boost_1_68/lib64-msvc-14.0;C:/local/boost_1_67_0/lib64-msvc-14.2;C:/local/boost_1_67_0/lib64-msvc-14.1;C:/local/boost_1_67_0/lib64-msvc-14.0;C:/local/boost_1_67/lib64-msvc-14.2;C:/local/boost_1_67/lib64-msvc-14.1;C:/local/boost_1_67/lib64-msvc-14.0;C:/local/boost_1_66_0/lib64-msvc-14.2;C:/local/boost_1_66_0/lib64-msvc-14.1;C:/local/boost_1_66_0/lib64-msvc-14.0;C:/local/boost_1_66/lib64-msvc-14.2;C:/local/boost_1_66/lib64-msvc-14.1;C:/local/boost_1_66/lib64-msvc-14.0;C:/local/boost_1_65_1/lib64-msvc-14.2;C:/local/boost_1_65_1/lib64-msvc-14.1;C:/local/boost_1_65_1/lib64-msvc-14.0;C:/local/boost_1_65_0/lib64-msvc-14.2;C:/local/boost_1_65_0/lib64-msvc-14.1;C:/local/boost_1_65_0/lib64-msvc-14.0;C:/local/boost_1_65/lib64-msvc-14.2;C:/local/boost_1_65/lib64-msvc-14.1;C:/local/boost_1_65/lib64-msvc-14.0;C:/boost/lib64-msvc-14.2;C:/boost/lib64-msvc-14.1;C:/boost/lib64-msvc-14.0;PATHS;C:/boost/lib;C:/boost;/sw/local/lib"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1839 ] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "D:/lib/boost_1_70_0/lib;D:/lib/boost_1_70_0/stage/lib;D:/lib/boost_1_70_0/lib64-msvc-14.2;D:/lib/boost_1_70_0/lib64-msvc-14.1;D:/lib/boost_1_70_0/lib64-msvc-14.0;D:/lib/boost_1_70_0/lib;D:/lib/boost_1_70_0/../lib;D:/lib/boost_1_70_0/stage/lib;D:/lib/boost_1_70_0/../lib64-msvc-14.2;D:/lib/boost_1_70_0/../lib64-msvc-14.1;D:/lib/boost_1_70_0/../lib64-msvc-14.0;D:/lib/boost_1_70_0/lib64-msvc-14.2;D:/lib/boost_1_70_0/lib64-msvc-14.1;D:/lib/boost_1_70_0/lib64-msvc-14.0;C:/local/boost_1_72_0/lib64-msvc-14.2;C:/local/boost_1_72_0/lib64-msvc-14.1;C:/local/boost_1_72_0/lib64-msvc-14.0;C:/local/boost_1_72/lib64-msvc-14.2;C:/local/boost_1_72/lib64-msvc-14.1;C:/local/boost_1_72/lib64-msvc-14.0;C:/local/boost_1_71_0/lib64-msvc-14.2;C:/local/boost_1_71_0/lib64-msvc-14.1;C:/local/boost_1_71_0/lib64-msvc-14.0;C:/local/boost_1_71/lib64-msvc-14.2;C:/local/boost_1_71/lib64-msvc-14.1;C:/local/boost_1_71/lib64-msvc-14.0;C:/local/boost_1_70_0/lib64-msvc-14.2;C:/local/boost_1_70_0/lib64-msvc-14.1;C:/local/boost_1_70_0/lib64-msvc-14.0;C:/local/boost_1_70/lib64-msvc-14.2;C:/local/boost_1_70/lib64-msvc-14.1;C:/local/boost_1_70/lib64-msvc-14.0;C:/local/boost_1_69_0/lib64-msvc-14.2;C:/local/boost_1_69_0/lib64-msvc-14.1;C:/local/boost_1_69_0/lib64-msvc-14.0;C:/local/boost_1_69/lib64-msvc-14.2;C:/local/boost_1_69/lib64-msvc-14.1;C:/local/boost_1_69/lib64-msvc-14.0;C:/local/boost_1_68_0/lib64-msvc-14.2;C:/local/boost_1_68_0/lib64-msvc-14.1;C:/local/boost_1_68_0/lib64-msvc-14.0;C:/local/boost_1_68/lib64-msvc-14.2;C:/local/boost_1_68/lib64-msvc-14.1;C:/local/boost_1_68/lib64-msvc-14.0;C:/local/boost_1_67_0/lib64-msvc-14.2;C:/local/boost_1_67_0/lib64-msvc-14.1;C:/local/boost_1_67_0/lib64-msvc-14.0;C:/local/boost_1_67/lib64-msvc-14.2;C:/local/boost_1_67/lib64-msvc-14.1;C:/local/boost_1_67/lib64-msvc-14.0;C:/local/boost_1_66_0/lib64-msvc-14.2;C:/local/boost_1_66_0/lib64-msvc-14.1;C:/local/boost_1_66_0/lib64-msvc-14.0;C:/local/boost_1_66/lib64-msvc-14.2;C:/local/boost_1_66/lib64-msvc-14.1;C:/local/boost_1_66/lib64-msvc-14.0;C:/local/boost_1_65_1/lib64-msvc-14.2;C:/local/boost_1_65_1/lib64-msvc-14.1;C:/local/boost_1_65_1/lib64-msvc-14.0;C:/local/boost_1_65_0/lib64-msvc-14.2;C:/local/boost_1_65_0/lib64-msvc-14.1;C:/local/boost_1_65_0/lib64-msvc-14.0;C:/local/boost_1_65/lib64-msvc-14.2;C:/local/boost_1_65/lib64-msvc-14.1;C:/local/boost_1_65/lib64-msvc-14.0;C:/boost/lib64-msvc-14.2;C:/boost/lib64-msvc-14.1;C:/boost/lib64-msvc-14.0;PATHS;C:/boost/lib;C:/boost;/sw/local/lib"
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2024 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-vc142-mt-s-x64-1_70;libboost_filesystem-vc142-mt-s-x64;libboost_filesystem-vc142-mt-s;libboost_filesystem-vc141-mt-s-x64-1_70;libboost_filesystem-vc141-mt-s-x64;libboost_filesystem-vc141-mt-s;libboost_filesystem-vc140-mt-s-x64-1_70;libboost_filesystem-vc140-mt-s-x64;libboost_filesystem-vc140-mt-s;libboost_filesystem-mt-s-x64-1_70;libboost_filesystem-mt-s-x64;libboost_filesystem-mt-s;libboost_filesystem-mt;libboost_filesystem
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2079 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-vc142-mt-sgd-x64-1_70;libboost_filesystem-vc142-mt-sgd-x64;libboost_filesystem-vc142-mt-sgd;libboost_filesystem-vc141-mt-sgd-x64-1_70;libboost_filesystem-vc141-mt-sgd-x64;libboost_filesystem-vc141-mt-sgd;libboost_filesystem-vc140-mt-sgd-x64-1_70;libboost_filesystem-vc140-mt-sgd-x64;libboost_filesystem-vc140-mt-sgd;libboost_filesystem-mt-sgd-x64-1_70;libboost_filesystem-mt-sgd-x64;libboost_filesystem-mt-sgd;libboost_filesystem-mt;libboost_filesystem
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2024 ] Searching for UNIT_TEST_FRAMEWORK_LIBRARY_RELEASE: libboost_unit_test_framework-vc142-mt-s-x64-1_70;libboost_unit_test_framework-vc142-mt-s-x64;libboost_unit_test_framework-vc142-mt-s;libboost_unit_test_framework-vc141-mt-s-x64-1_70;libboost_unit_test_framework-vc141-mt-s-x64;libboost_unit_test_framework-vc141-mt-s;libboost_unit_test_framework-vc140-mt-s-x64-1_70;libboost_unit_test_framework-vc140-mt-s-x64;libboost_unit_test_framework-vc140-mt-s;libboost_unit_test_framework-mt-s-x64-1_70;libboost_unit_test_framework-mt-s-x64;libboost_unit_test_framework-mt-s;libboost_unit_test_framework-mt;libboost_unit_test_framework
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2079 ] Searching for UNIT_TEST_FRAMEWORK_LIBRARY_DEBUG: libboost_unit_test_framework-vc142-mt-sgd-x64-1_70;libboost_unit_test_framework-vc142-mt-sgd-x64;libboost_unit_test_framework-vc142-mt-sgd;libboost_unit_test_framework-vc141-mt-sgd-x64-1_70;libboost_unit_test_framework-vc141-mt-sgd-x64;libboost_unit_test_framework-vc141-mt-sgd;libboost_unit_test_framework-vc140-mt-sgd-x64-1_70;libboost_unit_test_framework-vc140-mt-sgd-x64;libboost_unit_test_framework-vc140-mt-sgd;libboost_unit_test_framework-mt-sgd-x64-1_70;libboost_unit_test_framework-mt-sgd-x64;libboost_unit_test_framework-mt-sgd;libboost_unit_test_framework-mt;libboost_unit_test_framework
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2024 ] Searching for PROGRAM_OPTIONS_LIBRARY_RELEASE: libboost_program_options-vc142-mt-s-x64-1_70;libboost_program_options-vc142-mt-s-x64;libboost_program_options-vc142-mt-s;libboost_program_options-vc141-mt-s-x64-1_70;libboost_program_options-vc141-mt-s-x64;libboost_program_options-vc141-mt-s;libboost_program_options-vc140-mt-s-x64-1_70;libboost_program_options-vc140-mt-s-x64;libboost_program_options-vc140-mt-s;libboost_program_options-mt-s-x64-1_70;libboost_program_options-mt-s-x64;libboost_program_options-mt-s;libboost_program_options-mt;libboost_program_options
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2079 ] Searching for PROGRAM_OPTIONS_LIBRARY_DEBUG: libboost_program_options-vc142-mt-sgd-x64-1_70;libboost_program_options-vc142-mt-sgd-x64;libboost_program_options-vc142-mt-sgd;libboost_program_options-vc141-mt-sgd-x64-1_70;libboost_program_options-vc141-mt-sgd-x64;libboost_program_options-vc141-mt-sgd;libboost_program_options-vc140-mt-sgd-x64-1_70;libboost_program_options-vc140-mt-sgd-x64;libboost_program_options-vc140-mt-sgd;libboost_program_options-mt-sgd-x64-1_70;libboost_program_options-mt-sgd-x64;libboost_program_options-mt-sgd;libboost_program_options-mt;libboost_program_options
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2024 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc142-mt-s-x64-1_70;libboost_system-vc142-mt-s-x64;libboost_system-vc142-mt-s;libboost_system-vc141-mt-s-x64-1_70;libboost_system-vc141-mt-s-x64;libboost_system-vc141-mt-s;libboost_system-vc140-mt-s-x64-1_70;libboost_system-vc140-mt-s-x64;libboost_system-vc140-mt-s;libboost_system-mt-s-x64-1_70;libboost_system-mt-s-x64;libboost_system-mt-s;libboost_system-mt;libboost_system
-- [ C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2079 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc142-mt-sgd-x64-1_70;libboost_system-vc142-mt-sgd-x64;libboost_system-vc142-mt-sgd;libboost_system-vc141-mt-sgd-x64-1_70;libboost_system-vc141-mt-sgd-x64;libboost_system-vc141-mt-sgd;libboost_system-vc140-mt-sgd-x64-1_70;libboost_system-vc140-mt-sgd-x64;libboost_system-vc140-mt-sgd;libboost_system-mt-sgd-x64-1_70;libboost_system-mt-sgd-x64;libboost_system-mt-sgd;libboost_system-mt;libboost_system
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Boost (missing: filesystem unit_test_framework
program_options system) (found suitable version "1.70.0", minimum required
is "1.65.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2145 (find_package_handle_standard_args)
cmake/EthDependencies.cmake:34 (find_package)
CMakeLists.txt:42 (include)
从上面的输出中可以看到【BOOST_LIBRARYDIR】变量在cmake里显示未设置,导致后面cmake去找【_boost_LIBRARY_SEARCH_DIRS_RELEASE】即库的寻找目录时,设置了一些默认的路径,这些路径跟我电脑上的不一样,最终导致在找【FILESYSTEM_LIBRARY_RELEASE】等库的时候找不到,因此到这里我知道了,还是库的路径不对,库的路径要直接到库所在文件夹:【boost_1_70_0\stage64\lib】,所以直接添加【-DBOOST_LIBRARYDIR=“path/to/boost/lib”】的选项,指向实际有那些库的路径。然后就解决问题了!
后面再使用cmake找boost遇到什么问题都可以添加【-DBoost_DEBUG=ON】来分析具体错误原因,非常实用!