我在构建 SOCI 库时遇到困难。
相关软件:
- 加速版 1.73.0
- CMake ver 3.16
- MSVC 编译器版本 19.26.28805.0
- MySQL 版本 5.7
- 社会规范 4.0.0 版
相关路径:
- 提升之路
E:cppLibboostboost_1_73_0
. - 通往CMake的路径是
E:AppsCMakesharecmake-3.16
. - MySQL 服务器的路径是
C:Program FilesMySQLMySQL Server 5.7
。 - MSVC 的路径是
C:Apps32MicrosoftVisual Studio2019CommunityVCToolsMSVC14.26.28801binHostx64x64
。
构建 SOCI 的命令cmake -DCMAKE_BUILD_TYPE=Debut -DSOCI_CXX11=ON -DSOCI_SHARED=ON -DWITH_BOOST=ON -DWITH_MYSQL=ON ..
这是修改后的Boost.cmake
文件,可在%SOCI%cmakedependencies
中找到。注释开头##
解释更改。
## commented
#set(Boost_FIND_QUIETLY TRUE)
set(Boost_USE_MULTITHREADED ON)
## commented
#find_package(Boost 1.33.1 COMPONENTS date_time)
## BEGIN inserted
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "E:/cpp/Lib/boost/boost_1_73_0")
message(STATUS "<< set CMAKE_INCLUDE_PATH >> " ${CMAKE_INCLUDE_PATH})
set(BOOST_ROOT E:/cpp/Lib/boost/boost_1_73_0)
message(STATUS "<< set BOOST_ROOT >> " ${BOOST_ROOT})
message(STATUS "<< FIND_PACKAGE >>")
FIND_PACKAGE(Boost)
message(STATUS "<< FIND_PACKAGE COMPONENTS >>")
FIND_PACKAGE(Boost COMPONENTS date_time)
message(STATUS "<< Boost_FOUND >> " ${Boost_FOUND})
message(STATUS "<< Boost_DATE_TIME_FOUND >> " ${Boost_DATE_TIME_FOUND})
## END inserted
## commented
#if (NOT Boost_DATE_TIME_FOUND)
# find_package(Boost 1.33.1)
#endif()
set(Boost_RELEASE_VERSION
"${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
boost_external_report(Boost RELEASE_VERSION INCLUDE_DIR LIBRARIES)
这是相关输出。此处提供完整输出。
-- Boost:
-- << set CMAKE_INCLUDE_PATH >> E:/cpp/Lib/boost/boost_1_73_0
-- << set BOOST_ROOT >> E:/cpp/Lib/boost/boost_1_73_0
-- << FIND_PACKAGE >>
-- << FIND_PACKAGE COMPONENTS >>
CMake Warning at E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
cmake/dependencies/Boost.cmake:18 (FIND_PACKAGE)
cmake/SociDependencies.cmake:79 (include)
CMakeLists.txt:83 (include)
-- Could NOT find Boost (missing: date_time) (found version "1.73.0")
-- << Boost_FOUND >> FALSE
-- << Boost_DATE_TIME_FOUND >> 0
-- WARNING: Boost libraries not found, some features will be disabled.
执行msbuild.exe SOCI.sln
将生成此处可用的输出。
谁能告诉我为什么 SOCI 无法正确构建?为什么当它肯定存在时找不到date_time
组件?
事实证明,我得到的大部分错误都来自包含的单元测试。为什么?我不知道。但是,如果我忽略错误并继续前进,一切似乎都很好。